diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b65cc58ef..badffc2b1 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -43,7 +43,7 @@ If you don't see your idea listed, and you think it can contribute to Hush, do o ## Style guide -Don't write shitty code. +Don't write shitty code. Try to avoid emulating jl777 code style, which is like a rabbit donkey smoked bath salts with nothing to read but a K+R C book. ## Setting up your environment diff --git a/makeReleaseMac.sh b/makeReleaseMac.sh deleted file mode 100755 index 171ccb43f..000000000 --- a/makeReleaseMac.sh +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash -# Copyright ? various authors too lazy to put a copyright header -# Copyright 2019 The Hush Developers - -PACKAGE_DIR="$@" -mkdir ${PACKAGE_DIR} -echo "Created ${PACKAGE_DIR}" - -binaries=("komodo-cli" "komodod") -alllibs=() -for binary in "${binaries[@]}"; -do - echo "Processing binary ${binary}" - # do the work in the destination directory - cp src/${binary} ${PACKAGE_DIR} - # find the dylibs to copy for komodod - DYLIBS=`otool -L ${PACKAGE_DIR}/${binary} | grep "/usr/local" | awk -F' ' '{ print $1 }'` - echo "copying ${DYLIBS} to ${PACKAGE_DIR}" - # copy the dylibs to the srcdir - for dylib in ${DYLIBS}; do cp -rf ${dylib} ${PACKAGE_DIR}; done -done - -libraries=("libgcc_s.1.dylib" "libgomp.1.dylib" "libidn2.0.dylib" "libstdc++.6.dylib") - -for binary in "${libraries[@]}"; -do - echo "Processing binary ${binary}" - # find the dylibs to copy for komodod - DYLIBS=`otool -L ${PACKAGE_DIR}/${binary} | grep "/usr/local" | awk -F' ' '{ print $1 }'` - echo "copying ${DYLIBS} to ${PACKAGE_DIR}" - # copy the dylibs to the srcdir - for dylib in ${DYLIBS}; do cp -rf ${dylib} ${PACKAGE_DIR}; alllibs+=(${dylib}); done -done - -indirectlibraries=("libintl.8.dylib" "libunistring.2.dylib") - -for binary in "${indirectlibraries[@]}"; -do - echo "Processing binary ${binary}" - # Need to undo this for the dylibs when we are done - chmod 755 src/${binary} - # find the dylibs to copy for komodod - DYLIBS=`otool -L ${PACKAGE_DIR}/${binary} | grep "/usr/local" | awk -F' ' '{ print $1 }'` - echo "copying indirect ${DYLIBS} to ${PACKAGE_DIR}" - # copy the dylibs to the dest dir - for dylib in ${DYLIBS}; do cp -rf ${dylib} ${PACKAGE_DIR}; alllibs+=(${dylib}); done -done - -for binary in "${binaries[@]}"; -do - echo "Processing binary ${binary}" - # modify komodod to point to dylibs - echo "modifying ${binary} to use local libraries" - for dylib in "${alllibs[@]}" - do - echo "Next lib is ${dylib} " - install_name_tool -change ${dylib} @executable_path/`basename ${dylib}` ${PACKAGE_DIR}/${binary} - done - chmod +x ${PACKAGE_DIR}/${binary} -done - -for binary in "${libraries[@]}"; -do - echo "Processing binary ${binary}" - # modify libraries to point to dylibs - echo "modifying ${binary} to use local libraries" - for dylib in "${alllibs[@]}" - do - echo "Next lib is ${dylib} " - install_name_tool -change ${dylib} @executable_path/`basename ${dylib}` ${PACKAGE_DIR}/${binary} - done -done diff --git a/resolve.sh b/resolve.sh deleted file mode 100755 index 548e71dee..000000000 --- a/resolve.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -for f in $(git diff --name-only --diff-filter=U | cat); do - echo "Resolve conflict in $f ..." - git checkout --theirs $f -done - -for f in $(git diff --name-only --diff-filter=U | cat); do - echo "Adding file $f ..." - git add $f -done - diff --git a/src/ac/axo b/src/ac/axo deleted file mode 100755 index 18d38cac0..000000000 --- a/src/ac/axo +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=AXO $1 $2 $3 $4 $5 $6 diff --git a/src/ac/beer b/src/ac/beer deleted file mode 100755 index 34317bb93..000000000 --- a/src/ac/beer +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=BEER $1 $2 $3 $4 $5 $6 diff --git a/src/ac/bet b/src/ac/bet deleted file mode 100755 index ed99ce59f..000000000 --- a/src/ac/bet +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=BET $1 $2 $3 $4 $5 $6 diff --git a/src/ac/bntn b/src/ac/bntn deleted file mode 100755 index 7ae6f4e8d..000000000 --- a/src/ac/bntn +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=BNTN $1 $2 $3 $4 $5 $6 diff --git a/src/ac/bots b/src/ac/bots deleted file mode 100755 index 15c0fc288..000000000 --- a/src/ac/bots +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=BOTS $1 $2 $3 $4 $5 $6 diff --git a/src/ac/btch b/src/ac/btch deleted file mode 100755 index 6a57ea8d1..000000000 --- a/src/ac/btch +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=BTCH $1 $2 $3 $4 $5 $6 diff --git a/src/ac/ccl b/src/ac/ccl deleted file mode 100755 index c3d03a0a4..000000000 --- a/src/ac/ccl +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=CCL $1 $2 $3 $4 $5 $6 diff --git a/src/ac/ceal b/src/ac/ceal deleted file mode 100755 index 0cbeba67b..000000000 --- a/src/ac/ceal +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=CEAL $1 $2 $3 $4 $5 $6 diff --git a/src/ac/chain b/src/ac/chain deleted file mode 100755 index c55d30fbd..000000000 --- a/src/ac/chain +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=CHAIN $1 $2 $3 $4 $5 $6 diff --git a/src/ac/coquicash b/src/ac/coquicash deleted file mode 100755 index c882b2239..000000000 --- a/src/ac/coquicash +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=COQUICASH $1 $2 $3 $4 $5 $6 diff --git a/src/ac/crypto b/src/ac/crypto deleted file mode 100755 index 5a3d46188..000000000 --- a/src/ac/crypto +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=CRYPTO $1 $2 $3 $4 $5 $6 diff --git a/src/ac/dex b/src/ac/dex deleted file mode 100755 index 67331201a..000000000 --- a/src/ac/dex +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=DEX $1 $2 $3 $4 $5 $6 diff --git a/src/ac/dion b/src/ac/dion deleted file mode 100755 index 889f9e1ad..000000000 --- a/src/ac/dion +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=DION $1 $2 $3 $4 $5 $6 diff --git a/src/ac/dsec b/src/ac/dsec deleted file mode 100755 index a050ca94f..000000000 --- a/src/ac/dsec +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=DSEC $1 $2 $3 $4 $5 $6 diff --git a/src/ac/eql b/src/ac/eql deleted file mode 100755 index 99cfa9a09..000000000 --- a/src/ac/eql +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=EQL $1 $2 $3 $4 $5 $6 diff --git a/src/ac/etomic b/src/ac/etomic deleted file mode 100755 index 76eb0191c..000000000 --- a/src/ac/etomic +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=ETOMIC $1 $2 $3 $4 $5 $6 diff --git a/src/ac/glxt b/src/ac/glxt deleted file mode 100755 index 6cedfbf87..000000000 --- a/src/ac/glxt +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=GLXT $1 $2 $3 $4 $5 $6 diff --git a/src/ac/hodl b/src/ac/hodl deleted file mode 100755 index a5430db59..000000000 --- a/src/ac/hodl +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=HODL $1 $2 $3 $4 $5 $6 diff --git a/src/ac/ilien b/src/ac/ilien deleted file mode 100755 index 53e571661..000000000 --- a/src/ac/ilien +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=ILN $1 $2 $3 $4 $5 $6 - diff --git a/src/ac/iln b/src/ac/iln deleted file mode 100755 index f453c338e..000000000 --- a/src/ac/iln +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=ILN $1 $2 $3 $4 $5 $6 diff --git a/src/ac/jumblr b/src/ac/jumblr deleted file mode 100755 index 2969c5009..000000000 --- a/src/ac/jumblr +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=JUMBLR $1 $2 $3 $4 $5 $6 diff --git a/src/ac/k64 b/src/ac/k64 deleted file mode 100755 index a3b3bc835..000000000 --- a/src/ac/k64 +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=K64 $1 $2 $3 $4 $5 $6 diff --git a/src/ac/kmdice b/src/ac/kmdice deleted file mode 100755 index ca91bf9a5..000000000 --- a/src/ac/kmdice +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=KMDICE $1 $2 $3 $4 $5 $6 diff --git a/src/ac/koin b/src/ac/koin deleted file mode 100755 index 7e76c6b54..000000000 --- a/src/ac/koin +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=KOIN $1 $2 $3 $4 $5 $6 diff --git a/src/ac/ksb b/src/ac/ksb deleted file mode 100755 index 450c3b3f6..000000000 --- a/src/ac/ksb +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=KSB $1 $2 $3 $4 $5 $6 diff --git a/src/ac/kv b/src/ac/kv deleted file mode 100755 index 997fccb33..000000000 --- a/src/ac/kv +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=KV $1 $2 $3 $4 $5 $6 diff --git a/src/ac/mesh b/src/ac/mesh deleted file mode 100755 index 19b359509..000000000 --- a/src/ac/mesh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=MESH $1 $2 $3 $4 $5 $6 diff --git a/src/ac/mgnx b/src/ac/mgnx deleted file mode 100755 index 9bd85336e..000000000 --- a/src/ac/mgnx +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=MGNX $1 $2 $3 $4 $5 $6 diff --git a/src/ac/mgw b/src/ac/mgw deleted file mode 100755 index 9afa86b7a..000000000 --- a/src/ac/mgw +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=MGW $1 $2 $3 $4 $5 $6 diff --git a/src/ac/mnz b/src/ac/mnz deleted file mode 100755 index f4e1f3501..000000000 --- a/src/ac/mnz +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=MNZ $1 $2 $3 $4 $5 $6 diff --git a/src/ac/morty b/src/ac/morty deleted file mode 100755 index 4579324b7..000000000 --- a/src/ac/morty +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=MORTY $1 $2 $3 $4 $5 $6 diff --git a/src/ac/mshark b/src/ac/mshark deleted file mode 100755 index 1f0c950c6..000000000 --- a/src/ac/mshark +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=MSHARK $1 $2 $3 $4 $5 $6 diff --git a/src/ac/ninja b/src/ac/ninja deleted file mode 100755 index f7722abb0..000000000 --- a/src/ac/ninja +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=NINJA $1 $2 $3 $4 $5 $6 diff --git a/src/ac/oot b/src/ac/oot deleted file mode 100755 index 4c7c6b683..000000000 --- a/src/ac/oot +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=OOT $1 $2 $3 $4 $5 $6 diff --git a/src/ac/our b/src/ac/our deleted file mode 100755 index 66c774476..000000000 --- a/src/ac/our +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=OUR $1 $2 $3 $4 $5 $6 diff --git a/src/ac/pangea b/src/ac/pangea deleted file mode 100755 index 9920189ea..000000000 --- a/src/ac/pangea +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=PANGEA $1 $2 $3 $4 $5 $6 diff --git a/src/ac/pgt b/src/ac/pgt deleted file mode 100755 index 8e124bbd1..000000000 --- a/src/ac/pgt +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=PGT $1 $2 $3 $4 $5 $6 diff --git a/src/ac/pirate b/src/ac/pirate deleted file mode 100755 index 9314209da..000000000 --- a/src/ac/pirate +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=PIRATE $1 $2 $3 $4 $5 $6 diff --git a/src/ac/pizza b/src/ac/pizza deleted file mode 100755 index d8400d9d3..000000000 --- a/src/ac/pizza +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=PIZZA $1 $2 $3 $4 $5 $6 diff --git a/src/ac/prlpay b/src/ac/prlpay deleted file mode 100755 index 3d1063d13..000000000 --- a/src/ac/prlpay +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=PRLPAY $1 $2 $3 $4 $5 $6 diff --git a/src/ac/revs b/src/ac/revs deleted file mode 100755 index b898eb5dc..000000000 --- a/src/ac/revs +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=REVS $1 $2 $3 $4 $5 $6 diff --git a/src/ac/rick b/src/ac/rick deleted file mode 100755 index b68bd56ab..000000000 --- a/src/ac/rick +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=RICK $1 $2 $3 $4 $5 $6 diff --git a/src/ac/supernet b/src/ac/supernet deleted file mode 100755 index d841ffa0e..000000000 --- a/src/ac/supernet +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=SUPERNET $1 $2 $3 $4 $5 $6 diff --git a/src/ac/thc b/src/ac/thc deleted file mode 100755 index 84f9ea69c..000000000 --- a/src/ac/thc +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=THC $1 $2 $3 $4 $5 $6 diff --git a/src/ac/vote2018 b/src/ac/vote2018 deleted file mode 100755 index 4e385d76f..000000000 --- a/src/ac/vote2018 +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=VOTE2018 $1 $2 $3 $4 $5 $6 diff --git a/src/ac/vote2019 b/src/ac/vote2019 deleted file mode 100755 index 029558808..000000000 --- a/src/ac/vote2019 +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=VOTE2019 $1 $2 $3 $4 $5 $6 diff --git a/src/ac/wlc b/src/ac/wlc deleted file mode 100755 index ef7c47b90..000000000 --- a/src/ac/wlc +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=WLC $1 $2 $3 $4 $5 $6 diff --git a/src/ac/zexo b/src/ac/zexo deleted file mode 100755 index b6fd508f2..000000000 --- a/src/ac/zexo +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=ZEXO $1 $2 $3 $4 $5 $6 diff --git a/src/assetchains.json b/src/assetchains.json deleted file mode 100644 index 23a8ea959..000000000 --- a/src/assetchains.json +++ /dev/null @@ -1,337 +0,0 @@ -[ - { - "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": "COQUICASH", - "ac_supply": "72000000", - "ac_reward": "7200000000", - "ac_staked": "50", - "ac_halving": "420000", - "ac_cc": "2", - "ac_ccenable": "227,235,236,241", - "addnode": [ - "78.47.108.168" - ] - }, - { - "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": "AXO", - "ac_supply": "200000000", - "ac_ccactivate": "130000" - }, - { - "ac_name": "ETOMIC", - "ac_supply": "100000000" - }, - { - "ac_name": "BTCH", - "ac_supply": "20998641" - }, - { - "ac_name": "NINJA", - "ac_supply": "100000000" - }, - { - "ac_name": "OOT", - "ac_supply": "216000000", - "ac_sapling": "5000000" - }, - { - "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": "EQL", - "ac_supply": "500000000", - "ac_ccactivate": "205000" - }, - { - "ac_name": "ZILLA", - "ac_supply": "11000000", - "ac_sapling": "5000000", - "addnode": [ - "51.68.215.104" - ] - }, - { - "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", - "addnode": [ - "142.93.136.89", - "195.201.22.89" - ] - }, - { - "ac_name": "PIRATE", - "ac_supply": "0", - "ac_reward": "25600000000", - "ac_halving": "77777", - "ac_private": "1", - "addnode": [ - "136.243.102.225" - ] - }, - { - "ac_name": "PGT", - "ac_supply": "10000000", - "ac_end": "1", - "addnode": [ - "190.114.254.104" - ] - }, - { - "ac_name": "DION", - "ac_supply": "3900000000", - "ac_reward": "22260000000", - "ac_staked": "100", - "ac_cc": "1", - "ac_end": "4300000000", - "addnode": [ - "51.75.124.34" - ] - }, - { - "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": "KSB", - "ac_supply": "1000000000", - "ac_end": "1", - "ac_public": "1", - "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" - ] - }, - { - "ac_name": "ILN", - "ac_supply": "10000000000", - "ac_cc": "2", - "addnode": ["51.75.122.83"] - }, - { - "ac_name": "RICK", - "ac_supply": "90000000000", - "ac_reward": "100000000", - "ac_cc": "3", - "ac_staked": "10", - "addnode": [ - "138.201.136.145", - "95.217.44.58" - ] - }, - { - "ac_name": "MORTY", - "ac_supply": "90000000000", - "ac_reward": "100000000", - "ac_cc": "3", - "ac_staked": "10", - "addnode": [ - "138.201.136.145", - "95.217.44.58" - ] - }, - { - "ac_name": "KOIN", - "ac_supply": "125000000", - "addnode": ["3.0.32.10"] - }, - { - "ac_name": "ZEXO", - "ac_reward": "1478310502", - "ac_halving": "525600", - "ac_cc": "42", - "ac_ccenable": "236", - "ac_supply": "100000000", - "ac_perc": "77700", - "ac_staked": "93", - "ac_pubkey": "02713bd85e054db923694b6b7a85306264edf4d6bd6d331814f2b40af444b3ebbc", - "ac_public": "1", - "addnode": [ - "195.201.20.230", - "80.240.17.222" - ] - }, - { - "ac_name": "K64", - "ac_reward": "0", - "ac_supply": "64000777", - "ac_staked": "10", - "addnode": ["18.197.20.21"] - }, - { - "ac_name": "HUSH3", - "ac_sapling": "1", - "ac_founders": "1", - "ac_reward": "0,1125000000,562500000", - "ac_end": "128,340000,5422111", - "ac_blocktime": "150", - "ac_supply": "6178674", - "ac_halving": "129,340000,840000", - "ac_cc": "2", - "ac_cclib": "hush3", - "ac_ccenable": "228,234,235,236,241", - "ac_perc": "11111111", - "ac_eras": "3", - "ac_script": "76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac", - "clientname": "GoldenSandtrout", - "addnode": [ - "188.165.212.101", - "136.243.227.142", - "5.9.224.250" - ] - }, - { - "ac_name": "THC", - "ac_supply": "251253103", - "ac_reward": "360000000,300000000,240000000,180000000,150000000,90000000,0", - "ac_staked": "100", - "ac_eras": "7", - "ac_end": "500001,1000001,1500001,2000001,2500001,4500001,0", - "ac_perc": "233333333", - "ac_cc": "2", - "ac_ccenable": "229,236,240", - "ac_script": "2ea22c8020987fad30df055db6fd922c3a57e55d76601229ed3da3b31340112e773df3d0d28103120c008203000401ccb8", - "ac_founders": "150", - "ac_cbmaturity": "1", - "ac_sapling": "1", - "earlytxid": "7e4a76259e99c9379551389e9f757fc5f46c33ae922a8644dc2b187af2a6adc1", - "addnode": [ - "157.230.45.184", - "165.22.52.123" - ] - }, - { - "ac_name": "COMMOD", - "ac_supply": "0", - "ac_reward": "204800000000,100000000", - "ac_end": "482130,0", - "ac_halving": "43830,525960", - "ac_decay": "50000000,10000000", - "ac_eras": "2", - "ac_cc": "777", - "ac_public": "1", - "addnode": [ - "34.246.186.176", - "34.251.151.148" - ] - }, - { - "ac_name": "WLC21", - "ac_supply": "21000000", - "ac_reward": "190258751", - "ac_staked": "90", - "ac_public": "1", - "addnode": [ - "37.187.225.231", - "51.38.38.134" - ] - } -] diff --git a/src/assetchains.old b/src/assetchains.old deleted file mode 100755 index 0a2c4fb7b..000000000 --- a/src/assetchains.old +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/bash -set -x -delay=60 -source pubkey.txt -echo $pubkey - -./komodod -pubkey=$pubkey -ac_name=REVS -ac_supply=1300000 -addnode=95.213.238.98 $1 & -./komodod -pubkey=$pubkey -ac_name=SUPERNET -ac_supply=816061 -addnode=95.213.238.98 $1 & -./komodod -pubkey=$pubkey -ac_name=DEX -ac_supply=999999 -addnode=95.213.238.98 $1 & -./komodod -pubkey=$pubkey -ac_name=PANGEA -ac_supply=999999 -addnode=95.213.238.98 $1 & -./komodod -pubkey=$pubkey -ac_name=JUMBLR -ac_supply=999999 -addnode=95.213.238.98 $1 & -./komodod -pubkey=$pubkey -ac_name=BET -ac_supply=999999 -addnode=95.213.238.98 $1 & -./komodod -pubkey=$pubkey -ac_name=CRYPTO -ac_supply=999999 -addnode=95.213.238.98 $1 & -./komodod -pubkey=$pubkey -ac_name=HODL -ac_supply=9999999 -addnode=95.213.238.98 $1 & -./komodod -pubkey=$pubkey -ac_name=MSHARK -ac_supply=1400000 -addnode=95.213.238.98 $1 & -./komodod -pubkey=$pubkey -ac_name=BOTS -ac_supply=999999 -addnode=95.213.238.98 $1 & -./komodod -pubkey=$pubkey -ac_name=MGW -ac_supply=999999 -addnode=95.213.238.98 $1 & -./komodod -pubkey=$pubkey -ac_name=COQUICASH -ac_supply=72000000 -ac_reward=7200000000 -ac_staked=50 -ac_halving=420000 -ac_cc=2 -ac_ccenable=227,235,236,241 -addnode=78.47.108.168 & -./komodod -pubkey=$pubkey -ac_name=WLC -ac_supply=210000000 -addnode=95.213.238.98 $1 & -./komodod -pubkey=$pubkey -ac_name=KV -ac_supply=1000000 -addnode=95.213.238.98 $1 & -./komodod -pubkey=$pubkey -ac_name=CEAL -ac_supply=366666666 -addnode=95.213.238.98 $1 & -./komodod -pubkey=$pubkey -ac_name=MESH -ac_supply=1000007 -addnode=95.213.238.98 $1 & -./komodod -pubkey=$pubkey -ac_name=AXO -ac_supply=200000000 -ac_ccactivate=130000 -addnode=95.213.238.98 & -./komodod -pubkey=$pubkey -ac_name=ETOMIC -ac_supply=100000000 -addnode=95.213.238.98 & -./komodod -pubkey=$pubkey -ac_name=BTCH -ac_supply=20998641 -addnode=95.213.238.98 & -#./komodod -pubkey=$pubkey -ac_name=BEER -ac_supply=100000000 -addnode=95.213.238.98 & -#./komodod -pubkey=$pubkey -ac_name=PIZZA -ac_supply=100000000 -addnode=95.213.238.98 & -./komodod -pubkey=$pubkey -ac_name=NINJA -ac_supply=100000000 -addnode=95.213.238.98 & -./komodod -pubkey=$pubkey -ac_name=OOT -ac_supply=216000000 -ac_sapling=5000000 -addnode=95.213.238.98 & -./komodod -pubkey=$pubkey -ac_name=BNTN -ac_supply=500000000 -addnode=95.213.238.98 & -./komodod -pubkey=$pubkey -ac_name=CHAIN -ac_supply=999999 -addnode=95.213.238.98 & -./komodod -pubkey=$pubkey -ac_name=PRLPAY -ac_supply=500000000 -addnode=13.250.226.125 & -./komodod -pubkey=$pubkey -ac_name=DSEC -ac_supply=7000000 -addnode=185.148.147.30 & -#./komodod -pubkey=$pubkey -ac_name=GLXT -ac_supply=10000000000 -addnode=13.230.224.15 & -./komodod -pubkey=$pubkey -ac_name=EQL -ac_supply=500000000 -ac_ccactivate=205000 -addnode=46.101.124.153 & -./komodod -pubkey=$pubkey -ac_name=ZILLA -ac_supply=11000000 -ac_sapling=5000000 -addnode=51.68.215.104 & -./komodod -pubkey=$pubkey -ac_name=RFOX -ac_supply=1000000000 -ac_reward=100000000 -addnode=95.213.238.98 & -./komodod -pubkey=$pubkey -ac_name=SEC -ac_cc=333 -ac_supply=1000000000 -addnode=185.148.145.43 & -./komodod -pubkey=$pubkey -ac_name=CCL -ac_supply=200000000 -ac_end=1 -ac_cc=2 -addressindex=1 -spentindex=1 -addnode=142.93.136.89 -addnode=195.201.22.89 & -./komodod -pubkey=$pubkey -ac_name=PIRATE -ac_supply=0 -ac_reward=25600000000 -ac_halving=77777 -ac_private=1 -addnode=178.63.77.56 & -#./komodod -pubkey=$pubkey -ac_name=MGNX -ac_supply=12465003 -ac_staked=90 -ac_reward=2000000000 -ac_halving=525960 -ac_cc=2 -ac_end=2629800 -addnode=142.93.27.180 & -./komodod -pubkey=$pubkey -ac_name=PGT -ac_supply=10000000 -ac_end=1 -addnode=190.114.254.104 & -./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=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 -ac_staked=10 -addnode=95.217.44.58 -addnode=138.201.136.145 & -./komodod -pubkey=$pubkey -ac_name=MORTY -ac_supply=90000000000 -ac_reward=100000000 -ac_cc=3 -ac_staked=10 -addnode=95.217.44.58 -addnode=138.201.136.145 & -./komodod -pubkey=$pubkey -ac_name=VOTE2019 -ac_supply=123651638 -ac_public=1 -addnode=95.213.238.98 & -./komodod -pubkey=$pubkey -ac_name=KOIN -ac_supply=125000000 -addnode=3.0.32.10 & -./komodod -pubkey=$pubkey -ac_name=ZEXO -ac_supply=100000000 -ac_reward=1478310502 -ac_halving=525600 -ac_cc=42 -ac_ccenable=236 -ac_perc=77700 -ac_staked=93 -ac_pubkey=02713bd85e054db923694b6b7a85306264edf4d6bd6d331814f2b40af444b3ebbc -ac_public=1 -addnode=80.240.17.222 & -./komodod -pubkey=$pubkey -ac_name=K64 -ac_supply=64000777 -ac_reward=0 -ac_staked=10 -addnode=18.197.20.211 & -./komodod -pubkey=$pubkey -ac_name=HUSH3 -ac_sapling=1 -ac_reward=0,1125000000,562500000 -ac_halving=129,340000,840000 -ac_end=128,340000,5422111 -ac_eras=3 -ac_blocktime=150 -ac_cc=2 -ac_ccenable=228,234,235,236,241 -ac_founders=1 -ac_supply=6178674 -ac_perc=11111111 -clientname=GoldenSandtrout -addnode=188.165.212.101 -addnode=136.243.227.142 -addnode=5.9.224.250 -ac_cclib=hush3 -ac_script=76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac & -./komodod -pubkey=$pubkey -ac_name=THC -ac_supply=251253103 -ac_reward=360000000,300000000,240000000,180000000,150000000,90000000,0 -ac_staked=100 -ac_eras=7 -ac_end=500001,1000001,1500001,2000001,2500001,4500001,0 -ac_perc=233333333 -ac_cc=2 -ac_ccenable=229,236,240 -ac_script=2ea22c8020987fad30df055db6fd922c3a57e55d76601229ed3da3b31340112e773df3d0d28103120c008203000401ccb8 -ac_founders=150 -ac_cbmaturity=1 -ac_sapling=1 -addnode=157.230.45.184 -addnode=165.22.52.123 -earlytxid=7e4a76259e99c9379551389e9f757fc5f46c33ae922a8644dc2b187af2a6adc1 & diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 1d28e2cc9..7535f881e 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -309,8 +309,8 @@ int32_t myGet_mempool_txs(std::vector &txs,uint8_t evalcode,uint8_ /// \endcond /// \cond INTERNAL -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); +int32_t dragon_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp); +int32_t dragon_rwbignum(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *endianedp); /// \endcond CScript GetScriptForMultisig(int nRequired, const std::vector& keys); diff --git a/src/cc/crypto777/OS_portable.h b/src/cc/crypto777/OS_portable.h index e0b185cbc..9599ebcfe 100755 --- a/src/cc/crypto777/OS_portable.h +++ b/src/cc/crypto777/OS_portable.h @@ -15,7 +15,7 @@ #ifndef OS_PORTABLEH #define OS_PORTABLEH -// iguana_OS has functions that invoke system calls. Whenever possible stdio and similar functions are use and most functions are fully portable and in this file. For things that require OS specific, the call is routed to iguana_OS_portable_* Usually, all but one OS can be handled with the same code, so iguana_OS_portable.c has most of this shared logic and an #ifdef iguana_OS_nonportable.c +// dragon_OS has functions that invoke system calls. Whenever possible stdio and similar functions are use and most functions are fully portable and in this file. For things that require OS specific, the call is routed to dragon_OS_portable_* Usually, all but one OS can be handled with the same code, so dragon_OS_portable.c has most of this shared logic and an #ifdef dragon_OS_nonportable.c #ifdef __APPLE__ //#define LIQUIDITY_PROVIDER 1 @@ -279,19 +279,19 @@ void *queue_clone(queue_t *clone,queue_t *queue,int32_t size); int32_t queue_size(queue_t *queue); char *mbstr(char *str,double n); -void iguana_memreset(struct OS_memspace *mem); -void iguana_mempurge(struct OS_memspace *mem); -void *iguana_meminit(struct OS_memspace *mem,char *name,void *ptr,int64_t totalsize,int32_t threadsafe); -void *iguana_memalloc(struct OS_memspace *mem,long size,int32_t clearflag); -int64_t iguana_memfree(struct OS_memspace *mem,void *ptr,int32_t size); +void dragon_memreset(struct OS_memspace *mem); +void dragon_mempurge(struct OS_memspace *mem); +void *dragon_meminit(struct OS_memspace *mem,char *name,void *ptr,int64_t totalsize,int32_t threadsafe); +void *dragon_memalloc(struct OS_memspace *mem,long size,int32_t clearflag); +int64_t dragon_memfree(struct OS_memspace *mem,void *ptr,int32_t size); // generic functions -bits256 iguana_merkle(char *symbol,bits256 *tree,int32_t txn_count); +bits256 dragon_merkle(char *symbol,bits256 *tree,int32_t txn_count); bits256 bits256_calctxid(char *symbol,uint8_t *serialized,int32_t len); int32_t unhex(char c); void touppercase(char *str); uint32_t is_ipaddr(char *str); -void iguana_bitmap(char *space,int32_t max,char *name); +void dragon_bitmap(char *space,int32_t max,char *name); double _pairaved(double valA,double valB); int32_t unstringbits(char *buf,uint64_t bits); uint64_t stringbits(char *str); @@ -383,26 +383,26 @@ void expand_ipbits(char *ipaddr,uint64_t ipbits); void escape_code(char *escaped,char *str); void SaM_PrepareIndices(void); -// iguana_serdes.c +// dragon_serdes.c #ifndef IGUANA_LOG2PACKETSIZE #define IGUANA_LOG2PACKETSIZE 22 #endif #ifndef IGUANA_MAXPACKETSIZE #define IGUANA_MAXPACKETSIZE (1 << IGUANA_LOG2PACKETSIZE) #endif -struct iguana_msghdr { uint8_t netmagic[4]; char command[12]; uint8_t serdatalen[4],hash[4]; } PACKED; +struct dragon_msghdr { uint8_t netmagic[4]; char command[12]; uint8_t serdatalen[4],hash[4]; } PACKED; -int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp); -int32_t iguana_validatehdr(char *symbol,struct iguana_msghdr *H); -int32_t iguana_rwbignum(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *endianedp); -int32_t iguana_sethdr(struct iguana_msghdr *H,const uint8_t netmagic[4],char *command,uint8_t *data,int32_t datalen); -uint8_t *iguana_varint16(int32_t rwflag,uint8_t *serialized,uint16_t *varint16p); -uint8_t *iguana_varint32(int32_t rwflag,uint8_t *serialized,uint16_t *varint16p); -uint8_t *iguana_varint64(int32_t rwflag,uint8_t *serialized,uint32_t *varint32p); -int32_t iguana_rwvarint(int32_t rwflag,uint8_t *serialized,uint64_t *varint64p); -int32_t iguana_rwvarint32(int32_t rwflag,uint8_t *serialized,uint32_t *int32p); -int32_t iguana_rwvarstr(int32_t rwflag,uint8_t *serialized,int32_t maxlen,char *endianedp); -int32_t iguana_rwmem(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp); +int32_t dragon_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp); +int32_t dragon_validatehdr(char *symbol,struct dragon_msghdr *H); +int32_t dragon_rwbignum(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *endianedp); +int32_t dragon_sethdr(struct dragon_msghdr *H,const uint8_t netmagic[4],char *command,uint8_t *data,int32_t datalen); +uint8_t *dragon_varint16(int32_t rwflag,uint8_t *serialized,uint16_t *varint16p); +uint8_t *dragon_varint32(int32_t rwflag,uint8_t *serialized,uint16_t *varint16p); +uint8_t *dragon_varint64(int32_t rwflag,uint8_t *serialized,uint32_t *varint32p); +int32_t dragon_rwvarint(int32_t rwflag,uint8_t *serialized,uint64_t *varint64p); +int32_t dragon_rwvarint32(int32_t rwflag,uint8_t *serialized,uint32_t *int32p); +int32_t dragon_rwvarstr(int32_t rwflag,uint8_t *serialized,int32_t maxlen,char *endianedp); +int32_t dragon_rwmem(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp); #define bits256_nonz(a) (((a).ulongs[0] | (a).ulongs[1] | (a).ulongs[2] | (a).ulongs[3]) != 0) bits256 bits256_ave(bits256 a,bits256 b); diff --git a/src/cc/dapps/Makefile b/src/cc/dapps/Makefile index 1fea27084..f74df15e5 100644 --- a/src/cc/dapps/Makefile +++ b/src/cc/dapps/Makefile @@ -1,16 +1,17 @@ # Copyright 2020 The Hush Developers -# just type make to compile all dapps -all: zmigrate oraclefeed +# Just type make to compile all dat dapp code, fellow cypherpunk -subatomic: - $(CC) subatomic.c -o subatomic -lm +# we no longer build zmigrate by default, nobody uses that fucking code +all: hushdex +hushdex: + $(CC) hushdex.c -o hushdex -lm + +# Just for historical knowledge, to study how fucking stupid +# ZEC+KMD were to still support sprout, to this day!!!!!!!! zmigrate: $(CC) zmigrate.c -o zmigrate -lm -oraclefeed: - $(CC) oraclefeed.c -o oraclefeed -lm - clean: - rm zmigrate oraclefeed + rm zmigrate diff --git a/src/cc/dapps/README.md b/src/cc/dapps/README.md index d59878d47..86930e87a 100644 --- a/src/cc/dapps/README.md +++ b/src/cc/dapps/README.md @@ -9,6 +9,8 @@ To compile all dapps in this directory: ## zmigrate - Sprout to Sapling Migration dApp This tool converts Sprout zaddress funds into Sapling funds in a new Sapling address. +This is not applicable to HUSH3, since we have no Sprout funds, but left for historical +purposes. ### Usage @@ -19,10 +21,52 @@ The above command may need to be run multiple times to complete the process. This CLI implementation will be called by GUI wallets, average users do not need to worry about using this low-level tool. -## oraclefeed - feed of price data using oracles +## HushDEX -### Usage +HushDEX forked from the Subatomic Decentralized App (dapp) and we focus purely +on privacy coin swaps, and specifically, shielded swaps between Zcash Protocol +coins. These are called z-swaps. - ./oraclefeed $ACNAME $ORACLETXID $MYPUBKEY $FORMAT $BINDTXID [refcoin_cli] +### Z-swap example + +Alice has 1 ZEC and wants to trade it for 5 HUSH, since she hears HushChat is +pretty awesome and ZEC just goes down in price, always. We represent this in +a diagram like this + + Alice (ZEC) <> Bob (HUSH) + +HushDEX is only concerns with Sapling shielded addresses (zaddrs) which start +with `zs1`. Even though ZEC supports Sprout addresses (which start with `zc`), +they cannot be used on HushDEX. Sprout is unsupported on HushDEX. + +So Alice must make sure her ZEC is in a Sapling zaddr, and then she can use +HushDEX on her computer, to z-swap with Bob, in a decentralized way, with +no centralized service. The system is not completely trustless, users must +trust the developers and miners on the relevant chains to not do nefarious +things. There is no central authority to decide who gets to do what, it's +peer-to-peer like BitTorrent or Tor. + +### Privacy Features of Z-Swaps + + * No KYC + * We will not feed the identity theft industry any more free data + * No IP address limiting + * It is trivial to pay for an IP address from any country in the world + * Alice's address never appears in public data + * Bob's address never appears in public data + * Consequently, Alice and Bob's address cannot be searched for on an explorer + * Since you can't see the address of any transaction, you cannot infer if + the same address appears as sender or receiver in many transactions. + * The amount of the transaction, how much ZEC and how much HUSH, is unknown + * It could be pennies or millions + * The exchange rate of the transaction never appears on the blockchain + * The exchange rate will be leaked to the network p2p layer, but it is never + recorded in blockchain history. If you are not there to record it, it is gone. + * Realistically, it's simple to run a malicious node which records all exchange rates + and so we assume an adversary does this + * Since the exchange rate of ZEC/HUSH is already public data, this is not considered valuable + information leakage. We are leaking the differential of CEX ZEC/HUSH exchange ratio to + this DEX's ratio. + * Adversaries watching all possible public data can infer exchange ratios but no amounts + or addresses, which is considered a massive blow against blockchain analysis. -Supported formats are L and Ihh. Price data from CoinDesk API. diff --git a/src/cc/dapps/dappinc.h b/src/cc/dapps/dappinc.h index 3c71dfdec..6a95adb29 100644 --- a/src/cc/dapps/dappinc.h +++ b/src/cc/dapps/dappinc.h @@ -349,7 +349,7 @@ cJSON *get_komodocli(char *refcoin,char **retstrp,char *acname,char *method,char sprintf(cmdstr,"%s %s %s %s %s %s %s %s %s > %s\n",REFCOIN_CLI,method,arg0,arg1,arg2,arg3,arg4,arg5,arg6,fname); //printf("ref.(%s) REFCOIN_CLI (%s)\n",refcoin,cmdstr); } -//fprintf(stderr,"system(%s)\n",cmdstr); + //fprintf(stderr,"system(%s)\n",cmdstr); system(cmdstr); *retstrp = 0; if ( (jsonstr= filestr(&fsize,fname)) != 0 ) @@ -364,12 +364,13 @@ cJSON *get_komodocli(char *refcoin,char **retstrp,char *acname,char *method,char return(retjson); } -cJSON *subatomic_cli(char *clistr,char **retstrp,char *method,char *arg0,char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6) +cJSON *hushdex_cli(char *clistr,char **retstrp,char *method,char *arg0,char *arg1,char *arg2,char *arg3,char *arg4,char *arg5,char *arg6) { long fsize; cJSON *retjson = 0; char cmdstr[32768],*jsonstr,fname[32768]; - sprintf(fname,"/tmp/subatomic_%s_%d",method,(rand() >> 17) % 10000); + //TODO: fix this shitty insecure jl777 fucktwattery + sprintf(fname,"/tmp/hushdex_%s_%d",method,(rand() >> 17) % 10000); sprintf(cmdstr,"%s %s %s %s %s %s %s %s %s > %s\n",clistr,method,arg0,arg1,arg2,arg3,arg4,arg5,arg6,fname); -//fprintf(stderr,"system(%s)\n",cmdstr); + //fprintf(stderr,"system(%s)\n",cmdstr); system(cmdstr); *retstrp = 0; if ( (jsonstr= filestr(&fsize,fname)) != 0 ) diff --git a/src/cc/dapps/subatomic.c b/src/cc/dapps/hushdex.c similarity index 78% rename from src/cc/dapps/subatomic.c rename to src/cc/dapps/hushdex.c index 2f6ebf824..bf97e658b 100644 --- a/src/cc/dapps/subatomic.c +++ b/src/cc/dapps/hushdex.c @@ -1,3 +1,4 @@ +// Copyright (c) 2019-2020 The Hush developers /****************************************************************************** * Copyright © 2014-2020 The SuperNET Developers. * * * @@ -13,18 +14,18 @@ * * ******************************************************************************/ -// build subatomic and put in path: git pull; gcc cc/dapps/subatomic.c -lm -o subatomic; cp subatomic /usr/bin +// build hushdex and put in path: git pull; gcc cc/dapps/hushdex.c -lm -o hushdex; cp hushdex /usr/bin // alice sends relcoin and gets basecoin -#define DEXP2P_CHAIN ((char *)"DEX") -#define DEXP2P_PUBKEYS ((char *)"subatomic") +#define DEXP2P_CHAIN ((char *)"ZEX") +#define DEXP2P_PUBKEYS ((char *)"hushdex") #include "dappinc.h" // for OTC mode, the following 4 functions are the only ones that should be needed to support a new "coin" -//int64_t subatomic_getbalance(char *coin); -//bits256 subatomic_coinpayment(int32_t OTCmode,char *coin,char *destaddr,uint64_t paytoshis,char *memostr); -//cJSON *subatomic_txidwait(char *coin,bits256 txid,char *hexstr,int32_t numseconds); -//int64_t subatomic_verifypayment(char *coin,cJSON *rawtx,uint64_t destsatoshis,char *destaddr); +//int64_t hushdex_getbalance(char *coin); +//bits256 hushdex_coinpayment(int32_t OTCmode,char *coin,char *destaddr,uint64_t paytoshis,char *memostr); +//cJSON *hushdex_txidwait(char *coin,bits256 txid,char *hexstr,int32_t numseconds); +//int64_t hushdex_verifypayment(char *coin,cJSON *rawtx,uint64_t destsatoshis,char *destaddr); // TODO: // address conversion @@ -43,9 +44,7 @@ #define SUBATOMIC_TIMEOUT 60 #define SUBATOMIC_LOCKTIME 3600 #define SUBATOMIC_TXFEE 10000 - #define SUBATOMIC_PRIORITY 5 - #define SUBATOMIC_OPENREQUEST 1 #define SUBATOMIC_APPROVED 2 #define SUBATOMIC_OPENED 3 @@ -80,12 +79,12 @@ struct msginfo struct abinfo alice,bob; } *Messages; -uint64_t subatomic_txfee(char *coin) +uint64_t hushdex_txfee(char *coin) { return(SUBATOMIC_TXFEE); } -char *subatomic_checkname(char *tmpstr,struct msginfo *mp,int32_t baserel,char *coin) +char *hushdex_checkname(char *tmpstr,struct msginfo *mp,int32_t baserel,char *coin) { int32_t i,n; cJSON *external,*item; char *coinstr,*clistr; struct coininfo *ptr; ptr = (baserel == 0) ? &mp->base : &mp->rel; @@ -130,16 +129,9 @@ char *subatomic_checkname(char *tmpstr,struct msginfo *mp,int32_t baserel,char * } if ( ptr->isexternal == 0 ) { - if ( strcmp(coin,"KMD") != 0 ) - { strcpy(ptr->acname,coin); strcpy(ptr->coinstr,""); - } - else - { - strcpy(ptr->coinstr,coin); strcpy(ptr->acname,""); - } } else { @@ -153,27 +145,26 @@ char *subatomic_checkname(char *tmpstr,struct msginfo *mp,int32_t baserel,char * for (i=1; coin[i]!=0; i++) if ( isupper(coin[i]) == 0 ) return(coin); - if ( strcmp(coin+1,"KMD") != 0 ) ptr->iszaddr = 1; return(coin+1); } } -int32_t subatomic_zonly(struct coininfo *coin) +int32_t hushdex_zonly(struct coininfo *coin) { if ( strcmp(coin->coin,"PIRATE") == 0 ) return(1); else return(coin->iszaddr); } -// //////////////////////////////// the four key functions needed to support a new item for subatomics +// //////////////////////////////// the four key functions needed to support a new item for hushdexs -int64_t _subatomic_getbalance(struct coininfo *coin) +int64_t _hushdex_getbalance(struct coininfo *coin) { cJSON *retjson; char *retstr,cmpstr[64]; int64_t amount=0; - if ( (retjson= subatomic_cli(coin->cli,&retstr,"getbalance","","","","","","","")) != 0 ) + if ( (retjson= hushdex_cli(coin->cli,&retstr,"getbalance","","","","","","","")) != 0 ) { - fprintf(stderr,"_subatomic_getbalance.(%s) %s returned json!\n",coin->coinstr,coin->cli); + fprintf(stderr,"_hushdex_getbalance.(%s) %s returned json!\n",coin->coinstr,coin->cli); free_json(retjson); } else if ( retstr != 0 ) @@ -188,14 +179,14 @@ int64_t _subatomic_getbalance(struct coininfo *coin) return (amount); } -bits256 _subatomic_sendtoaddress(struct coininfo *coin,char *destaddr,int64_t satoshis) +bits256 _hushdex_sendtoaddress(struct coininfo *coin,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= subatomic_cli(coin->cli,&retstr,"sendtoaddress",destaddr,numstr,"false","","","","")) != 0 ) + if ( (retjson= hushdex_cli(coin->cli,&retstr,"sendtoaddress",destaddr,numstr,"false","","","","")) != 0 ) { - fprintf(stderr,"unexpected _subatomic_sendtoaddress json.(%s)\n",jprint(retjson,0)); + fprintf(stderr,"unexpected _hushdex_sendtoaddress json.(%s)\n",jprint(retjson,0)); free_json(retjson); } else if ( retstr != 0 ) @@ -205,35 +196,31 @@ bits256 _subatomic_sendtoaddress(struct coininfo *coin,char *destaddr,int64_t sa retstr[64] = 0; decode_hex(txid.bytes,32,retstr); } - fprintf(stderr,"_subatomic_sendtoaddress %s %.8f txid.(%s)\n",destaddr,(double)satoshis/SATOSHIDEN,bits256_str(str,txid)); + fprintf(stderr,"_hushdex_sendtoaddress %s %.8f txid.(%s)\n",destaddr,(double)satoshis/SATOSHIDEN,bits256_str(str,txid)); free(retstr); } return(txid); } -cJSON *_subatomic_rawtransaction(struct coininfo *coin,bits256 txid) +cJSON *_hushdex_rawtransaction(struct coininfo *coin,bits256 txid) { cJSON *retjson; char *retstr,str[65]; - if ( (retjson= subatomic_cli(coin->cli,&retstr,"getrawtransaction",bits256_str(str,txid),"1","","","","","")) != 0 ) + if ( (retjson= hushdex_cli(coin->cli,&retstr,"getrawtransaction",bits256_str(str,txid),"1","","","","","")) != 0 ) { return(retjson); } else if ( retstr != 0 ) { - fprintf(stderr,"_subatomic_rawtransaction.(%s) %s error.(%s)\n",coin->coin,coin->name,retstr); + fprintf(stderr,"_hushdex_rawtransaction.(%s) %s error.(%s)\n",coin->coin,coin->name,retstr); free(retstr); } return(0); } -int64_t subatomic_getbalance(struct coininfo *coin) +int64_t hushdex_getbalance(struct coininfo *coin) { char *coinstr,*acname=""; FILE *fp; int64_t retval = 0; - if ( strcmp(coin->coin,"KMD") != 0 ) - { - acname = coin->coin; - coinstr = ""; - } else coinstr = coin->coin; + coinstr = coin->coin; if ( coin->isfile != 0 ) { if ( (fp= fopen(coin->name+1,"rb")) != 0 ) // if alice, add bob pubkey to fname @@ -243,7 +230,7 @@ int64_t subatomic_getbalance(struct coininfo *coin) } return(retval); } - else if ( subatomic_zonly(coin) != 0 ) + else if ( hushdex_zonly(coin) != 0 ) return(z_getbalance(coinstr,acname,DPOW_recvZaddr)); else { @@ -259,11 +246,11 @@ int64_t subatomic_getbalance(struct coininfo *coin) } else if ( coin->isexternal == 0 ) return(get_getbalance(coinstr,acname)); - else return(_subatomic_getbalance(coin)); + else return(_hushdex_getbalance(coin)); } } -bits256 subatomic_coinpayment(uint32_t origid,int32_t OTCmode,struct coininfo *coin,char *destaddr,uint64_t paytoshis,char *memostr,char *destpub,char *senderpub) +bits256 hushdex_coinpayment(uint32_t origid,int32_t OTCmode,struct coininfo *coin,char *destaddr,uint64_t paytoshis,char *memostr,char *destpub,char *senderpub) { bits256 txid; char opidstr[128],opretstr[32],str[65],*status,*coinstr,*acname=""; cJSON *retjson,*retjson2,*item,*res; int32_t i,pending=0; memset(&txid,0,sizeof(txid)); @@ -288,7 +275,7 @@ bits256 subatomic_coinpayment(uint32_t origid,int32_t OTCmode,struct coininfo *c fprintf(stderr,"end broadcast of (%s) to %s\n",coin->coin+1,senderpub); return(txid); } - else if ( subatomic_zonly(coin) != 0 ) + else if ( hushdex_zonly(coin) != 0 ) { if ( memostr[0] == 0 ) memostr = "beef"; @@ -327,24 +314,20 @@ bits256 subatomic_coinpayment(uint32_t origid,int32_t OTCmode,struct coininfo *c } else { - if ( strcmp(coin->coin,"KMD") != 0 ) - { - acname = coin->coin; - coinstr = ""; - } else coinstr = coin->coin; + coinstr = coin->coin; if ( coin->istoken != 0 ) txid = tokentransfer(coinstr,acname,coin->tokenid,destpub,paytoshis/SATOSHIDEN); else if ( coin->isexternal == 0 ) { sprintf(opretstr,"%08x",origid); txid = sendtoaddress(coinstr,acname,destaddr,paytoshis,opretstr); - } else txid = _subatomic_sendtoaddress(coin,destaddr,paytoshis); + } else txid = _hushdex_sendtoaddress(coin,destaddr,paytoshis); printf("%u got txid.%s\n",origid,bits256_str(str,txid)); } return(txid); } -cJSON *subatomic_txidwait(struct coininfo *coin,bits256 txid,char *hexstr,int32_t numseconds,char *senderpub) +cJSON *hushdex_txidwait(struct coininfo *coin,bits256 txid,char *hexstr,int32_t numseconds,char *senderpub) { int32_t i,zflag; char *coinstr,str[65],*acname=""; cJSON *rawtx; bits256 z; bits256 filehash; memset(&z,0,sizeof(z)); @@ -355,12 +338,8 @@ cJSON *subatomic_txidwait(struct coininfo *coin,bits256 txid,char *hexstr,int32_ // compare against txid // if matches, sendrawtransaction if OTC mode, decoode and return if channels mode } - zflag = (subatomic_zonly(coin) != 0); - if ( strcmp(coin->coin,"KMD") != 0 ) - { - acname = coin->coin; - coinstr = ""; - } else coinstr = coin->coin; + zflag = (hushdex_zonly(coin) != 0); + coinstr = coin->coin; for (i=0; iisfile != 0 ) @@ -380,7 +359,7 @@ cJSON *subatomic_txidwait(struct coininfo *coin,bits256 txid,char *hexstr,int32_ rawtx = get_z_viewtransaction(coinstr,acname,txid); else if ( coin->isexternal == 0 ) rawtx = get_rawtransaction(coinstr,acname,txid); - else rawtx = _subatomic_rawtransaction(coin,txid); + else rawtx = _hushdex_rawtransaction(coin,txid); if ( rawtx != 0 ) return(rawtx); sleep(1); @@ -389,7 +368,7 @@ cJSON *subatomic_txidwait(struct coininfo *coin,bits256 txid,char *hexstr,int32_ return(0); } -int64_t subatomic_verifypayment(struct coininfo *coin,cJSON *rawtx,uint64_t destsatoshis,char *destaddr,bits256 txid) +int64_t hushdex_verifypayment(struct coininfo *coin,cJSON *rawtx,uint64_t destsatoshis,char *destaddr,bits256 txid) { int32_t i,n,m,valid=0; bits256 tokenid,filehash,checkhash; cJSON *array,*item,*sobj,*a; char *addr,*acname,*coinstr,tokenaddr[64],*hex; uint8_t hexbuf[512],pub33[33]; uint64_t netval,recvsatoshis = 0; if ( coin->isfile != 0 ) @@ -402,7 +381,7 @@ int64_t subatomic_verifypayment(struct coininfo *coin,cJSON *rawtx,uint64_t dest return(SATOSHIDEN); } else return(0); } - else if ( subatomic_zonly(coin) != 0 ) + else if ( hushdex_zonly(coin) != 0 ) { if ( (array= jarray(&n,rawtx,"outputs")) != 0 && n > 0 ) { @@ -421,11 +400,7 @@ int64_t subatomic_verifypayment(struct coininfo *coin,cJSON *rawtx,uint64_t dest item = jitem(array,0); if ( (sobj= jobj(item,"scriptPubKey")) != 0 && (a= jarray(&m,sobj,"addresses")) != 0 && m == 1 ) { - if ( strcmp(coin->coin,"KMD") != 0 ) - { - acname = coin->coin; - coinstr = ""; - } else coinstr = coin->coin; + coinstr = coin->coin; if ( get_tokenaddress(coinstr,acname,tokenaddr) != 0 ) { //fprintf(stderr,"tokenaddr.%s\n",tokenaddr); @@ -473,14 +448,14 @@ int64_t subatomic_verifypayment(struct coininfo *coin,cJSON *rawtx,uint64_t dest } // //////////// end -struct msginfo *subatomic_find(uint32_t origid) +struct msginfo *hushdex_find(uint32_t origid) { struct msginfo *mp; HASH_FIND(hh,Messages,&origid,sizeof(origid),mp); return(mp); } -struct msginfo *subatomic_add(uint32_t origid) +struct msginfo *hushdex_add(uint32_t origid) { struct msginfo *mp = calloc(1,sizeof(*mp)); mp->origid = origid; @@ -488,7 +463,7 @@ struct msginfo *subatomic_add(uint32_t origid) return(mp); } -int32_t subatomic_status(struct msginfo *mp,int32_t status) +int32_t hushdex_status(struct msginfo *mp,int32_t status) { static FILE *fp; if ( fp == 0 ) @@ -526,9 +501,9 @@ int32_t subatomic_status(struct msginfo *mp,int32_t status) exit(-1); } //fprintf(stderr,"%u <- %d\n",oid,s); - if ( (m= subatomic_find(oid)) == 0 ) + if ( (m= hushdex_find(oid)) == 0 ) { - m = subatomic_add(oid); + m = hushdex_add(oid); count++; } if ( s > m->status ) @@ -549,18 +524,18 @@ int32_t subatomic_status(struct msginfo *mp,int32_t status) return(0); } -struct msginfo *subatomic_tracker(uint32_t origid) +struct msginfo *hushdex_tracker(uint32_t origid) { struct msginfo *mp; - if ( (mp= subatomic_find(origid)) == 0 ) + if ( (mp= hushdex_find(origid)) == 0 ) { - mp = subatomic_add(origid); - subatomic_status(mp,0); + mp = hushdex_add(origid); + hushdex_status(mp,0); } return(mp); } -char *subatomic_hexstr(char *jsonstr) +char *hushdex_hexstr(char *jsonstr) { char *hexstr; int32_t i,c,n = (int32_t)strlen(jsonstr); hexstr = malloc(2*n + 3); @@ -577,7 +552,7 @@ char *subatomic_hexstr(char *jsonstr) return(hexstr); } -cJSON *subatomic_mpjson(struct msginfo *mp) +cJSON *hushdex_mpjson(struct msginfo *mp) { cJSON *item; item = cJSON_CreateObject(); @@ -598,12 +573,12 @@ cJSON *subatomic_mpjson(struct msginfo *mp) jaddstr(item,"alicesecp",mp->alice.secp); jaddstr(item,"bob",mp->bob.pubkey); jaddstr(item,"bobsecp",mp->bob.secp); - if ( subatomic_zonly(&mp->rel) != 0 ) + if ( hushdex_zonly(&mp->rel) != 0 ) jaddstr(item,"bobZaddr",mp->bob.recvZaddr); else jaddstr(item,"bobaddr",mp->bob.recvaddr); if ( mp->rel.istoken != 0 ) jaddstr(item,"bobtoken",mp->rel.tokenid); - if ( subatomic_zonly(&mp->base) != 0 ) + if ( hushdex_zonly(&mp->base) != 0 ) jaddstr(item,"aliceZaddr",mp->alice.recvZaddr); else jaddstr(item,"aliceaddr",mp->alice.recvaddr); if ( mp->base.istoken != 0 ) @@ -611,19 +586,19 @@ cJSON *subatomic_mpjson(struct msginfo *mp) return(item); } -uint64_t subatomic_orderbook_mpset(struct msginfo *mp,char *basecheck) +uint64_t hushdex_orderbook_mpset(struct msginfo *mp,char *basecheck) { cJSON *retjson; char *tagA,*tagB,*senderpub,*str,tmpstr[32]; int32_t matches=0; double volA,volB; int64_t txfee=0; strcpy(mp->base.name,basecheck); - strcpy(mp->base.coin,subatomic_checkname(tmpstr,mp,0,basecheck)); - mp->rel.txfee = subatomic_txfee(mp->rel.coin); + strcpy(mp->base.coin,hushdex_checkname(tmpstr,mp,0,basecheck)); + mp->rel.txfee = hushdex_txfee(mp->rel.coin); if ( (retjson= dpow_get(mp->origid)) != 0 ) { //fprintf(stderr,"dpow_get.(%s) (%s/%s)\n",jprint(retjson,0),mp->base.coin,mp->rel.coin); if ( (senderpub= jstr(retjson,"senderpub")) != 0 && is_hexstr(senderpub,0) == 66 && (tagA= jstr(retjson,"tagA")) != 0 && (tagB= jstr(retjson,"tagB")) != 0 && strncmp(tagB,mp->rel.name,strlen(mp->rel.name)) == 0 && strlen(tagA) < sizeof(mp->base.name) ) { strcpy(mp->base.name,tagA); - strcpy(mp->base.coin,subatomic_checkname(tmpstr,mp,0,tagA)); + strcpy(mp->base.coin,hushdex_checkname(tmpstr,mp,0,tagA)); if ( basecheck[0] == 0 || strncmp(basecheck,tagA,strlen(basecheck)) == 0 ) matches = 1; else if ( strcmp(tagA,mp->base.name) == 0 ) @@ -635,7 +610,7 @@ uint64_t subatomic_orderbook_mpset(struct msginfo *mp,char *basecheck) if ( (str= jstr(retjson,"decrypted")) != 0 && strlen(str) < 128 ) strcpy(mp->payload,str); mp->locktime = juint(retjson,"timestamp") + SUBATOMIC_LOCKTIME; - mp->base.txfee = subatomic_txfee(mp->base.coin); + mp->base.txfee = hushdex_txfee(mp->base.coin); strcpy(mp->senderpub,senderpub); volB = jdouble(retjson,"amountB"); volA = jdouble(retjson,"amountA"); @@ -665,7 +640,7 @@ char *randhashstr(char *str) return(str); } -void subatomic_extrafields(cJSON *dest,cJSON *src) +void hushdex_extrafields(cJSON *dest,cJSON *src) { char *str; if ( (str= jstr(src,"approval")) != 0 ) @@ -694,12 +669,12 @@ void subatomic_extrafields(cJSON *dest,cJSON *src) jaddstr(dest,"bobtoken",str); } -char *subatomic_submit(cJSON *argjson,int32_t tobob) +char *hushdex_submit(cJSON *argjson,int32_t tobob) { char *jsonstr,*hexstr; jaddnum(argjson,"tobob",tobob != 0); jsonstr = jprint(argjson,1); - hexstr = subatomic_hexstr(jsonstr); + hexstr = hushdex_hexstr(jsonstr); free(jsonstr); return(hexstr); } @@ -720,7 +695,7 @@ char *subatomic_submit(cJSON *argjson,int32_t tobob) #define SCRIPT_OP_CHECKMULTISIGVERIFY 0xaf #define SCRIPT_OP_CHECKLOCKTIMEVERIFY 0xb1 -int32_t subatomic_redeemscript(char *redeemscript,uint32_t locktime,char *pubkeyA,char *pubkeyB) // not needed +int32_t hushdex_redeemscript(char *redeemscript,uint32_t locktime,char *pubkeyA,char *pubkeyB) // not needed { // if ( refund ) OP_HASH160 <2of2 multisig hash> OP_EQUAL // standard multisig // else CLTV OP_DROP OP_CHECKSIG // standard spend @@ -768,21 +743,16 @@ int32_t subatomic_redeemscript(char *redeemscript,uint32_t locktime,char *pubkey return(n); } -int32_t subatomic_approved(struct msginfo *mp,cJSON *approval,cJSON *msgjson,char *senderpub) +int32_t hushdex_approved(struct msginfo *mp,cJSON *approval,cJSON *msgjson,char *senderpub) { char *hexstr,numstr[32],redeemscript[1024],*coin,*acname=""; cJSON *retjson,*decodejson; int32_t i,retval = 0; - subatomic_extrafields(approval,msgjson); + hushdex_extrafields(approval,msgjson); if ( mp->OTCmode == 0 ) { coin = (mp->bobflag != 0) ? mp->base.coin : mp->rel.coin; // the other side gets this coin - if ( strcmp(coin,"KMD") != 0 ) - { - acname = coin; - coin = ""; - } if ( get_createmultisig2(coin,acname,mp->msigaddr,mp->redeemscript,mp->alice.secp,mp->bob.secp) != 0 ) { - subatomic_redeemscript(redeemscript,mp->locktime,mp->alice.secp,mp->bob.secp); + hushdex_redeemscript(redeemscript,mp->locktime,mp->alice.secp,mp->bob.secp); if ( (decodejson= get_decodescript(coin,acname,redeemscript)) != 0 ) { fprintf(stderr,"%s %s msigaddr.%s %s -> %s %s\n",mp->bobflag!=0?"bob":"alice",(mp->bobflag != 0) ? mp->base.coin : mp->rel.coin,mp->msigaddr,mp->redeemscript,redeemscript,jprint(decodejson,0)); @@ -797,51 +767,51 @@ int32_t subatomic_approved(struct msginfo *mp,cJSON *approval,cJSON *msgjson,cha i++; mp->approval[i<<1] = 0; jaddstr(approval,"approval",mp->approval); - hexstr = subatomic_submit(approval,!mp->bobflag); + hexstr = hushdex_submit(approval,!mp->bobflag); if ( (retjson= dpow_broadcast(SUBATOMIC_PRIORITY,hexstr,(char *)"inbox",(char *)"approved",senderpub,"","")) != 0 ) { if ( (mp->approvalid= juint(retjson,"id")) != 0 ) retval = 1; printf("%u approvalid.%u (%s)\n",mp->origid,mp->approvalid,senderpub); - subatomic_status(mp,SUBATOMIC_APPROVED); + hushdex_status(mp,SUBATOMIC_APPROVED); free_json(retjson); } free(hexstr); return(retval); } -int32_t subatomic_opened(struct msginfo *mp,cJSON *opened,cJSON *msgjson,char *senderpub) +int32_t hushdex_opened(struct msginfo *mp,cJSON *opened,cJSON *msgjson,char *senderpub) { char *hexstr,channelstr[65]; cJSON *retjson; int32_t retval = 0; - subatomic_extrafields(opened,msgjson); + hushdex_extrafields(opened,msgjson); jaddstr(opened,"opened",randhashstr(channelstr)); - hexstr = subatomic_submit(opened,!mp->bobflag); + hexstr = hushdex_submit(opened,!mp->bobflag); if ( (retjson= dpow_broadcast(SUBATOMIC_PRIORITY,hexstr,(char *)"inbox",(char *)"opened",senderpub,"","")) != 0 ) { if ( (mp->openedid= juint(retjson,"id")) != 0 ) retval = 1; printf("%u openedid.%u\n",mp->origid,mp->openedid); - subatomic_status(mp,SUBATOMIC_OPENED); + hushdex_status(mp,SUBATOMIC_OPENED); free_json(retjson); } free(hexstr); return(retval); } -int32_t subatomic_payment(struct msginfo *mp,cJSON *payment,cJSON *msgjson,char *senderpub) +int32_t hushdex_payment(struct msginfo *mp,cJSON *payment,cJSON *msgjson,char *senderpub) { bits256 txid; uint64_t paytoshis; cJSON *retjson; char numstr[32],*coin,*dest,*hexstr; int32_t retval = 0; if ( mp->bobflag == 0 ) { coin = mp->rel.name; paytoshis = mp->rel.satoshis; - if ( subatomic_zonly(&mp->rel) != 0 ) + if ( hushdex_zonly(&mp->rel) != 0 ) dest = mp->bob.recvZaddr; else dest = mp->bob.recvaddr; sprintf(numstr,"%llu",(long long)paytoshis); jaddstr(payment,"alicepays",numstr); jaddstr(payment,"bobdestaddr",dest); - txid = subatomic_coinpayment(mp->origid,mp->OTCmode,&mp->rel,dest,paytoshis,mp->approval,mp->bob.secp,senderpub); + txid = hushdex_coinpayment(mp->origid,mp->OTCmode,&mp->rel,dest,paytoshis,mp->approval,mp->bob.secp,senderpub); jaddbits256(payment,"alicepayment",txid); mp->alicepayment = txid; hexstr = 0; // get it from rawtransaction of txid @@ -851,60 +821,60 @@ int32_t subatomic_payment(struct msginfo *mp,cJSON *payment,cJSON *msgjson,char { coin = mp->base.name; paytoshis = mp->base.satoshis; - if ( subatomic_zonly(&mp->base) != 0 ) + if ( hushdex_zonly(&mp->base) != 0 ) dest = mp->alice.recvZaddr; else dest = mp->alice.recvaddr; sprintf(numstr,"%llu",(long long)paytoshis); jaddstr(payment,"bobpays",numstr); jaddstr(payment,"alicedestaddr",dest); - txid = subatomic_coinpayment(mp->origid,mp->OTCmode,&mp->base,dest,paytoshis,mp->approval,mp->alice.secp,senderpub); + txid = hushdex_coinpayment(mp->origid,mp->OTCmode,&mp->base,dest,paytoshis,mp->approval,mp->alice.secp,senderpub); jaddbits256(payment,"bobpayment",txid); mp->bobpayment = txid; hexstr = 0; // get it from rawtransaction of txid jaddstr(payment,"bobtx",hexstr); } - hexstr = subatomic_submit(payment,!mp->bobflag); + hexstr = hushdex_submit(payment,!mp->bobflag); if ( (retjson= dpow_broadcast(SUBATOMIC_PRIORITY,hexstr,(char *)"inbox",(char *)"payment",senderpub,"","")) != 0 ) { if ( (mp->paymentids[0]= juint(retjson,"id")) != 0 ) retval = 1; printf("%u: %.8f %s -> %s, paymentid[0] %u\n",mp->origid,dstr(paytoshis),coin,dest,mp->paymentids[0]); - subatomic_status(mp,SUBATOMIC_PAYMENT); + hushdex_status(mp,SUBATOMIC_PAYMENT); free_json(retjson); } free(hexstr); return(retval); } -int32_t subatomic_paidinfull(struct msginfo *mp,cJSON *paid,cJSON *msgjson,char *senderpub) +int32_t hushdex_paidinfull(struct msginfo *mp,cJSON *paid,cJSON *msgjson,char *senderpub) { char *hexstr; cJSON *retjson; int32_t retval = 0; jaddstr(paid,"paid","in full"); - subatomic_extrafields(paid,msgjson); - hexstr = subatomic_submit(paid,!mp->bobflag); + hushdex_extrafields(paid,msgjson); + hexstr = hushdex_submit(paid,!mp->bobflag); if ( (retjson= dpow_broadcast(SUBATOMIC_PRIORITY,hexstr,(char *)"inbox",(char *)"paid",senderpub,"","")) != 0 ) { if ( (mp->paidid= juint(retjson,"id")) != 0 ) retval = 1; printf("%u paidid.%u\n",mp->origid,mp->paidid); - subatomic_status(mp,SUBATOMIC_PAIDINFULL); + hushdex_status(mp,SUBATOMIC_PAIDINFULL); free_json(retjson); } free(hexstr); return(retval); } -int32_t subatomic_closed(struct msginfo *mp,cJSON *closed,cJSON *msgjson,char *senderpub) +int32_t hushdex_closed(struct msginfo *mp,cJSON *closed,cJSON *msgjson,char *senderpub) { char *hexstr; cJSON *retjson; int32_t retval = 0; jaddnum(closed,"closed",mp->origid); - subatomic_extrafields(closed,msgjson); - hexstr = subatomic_submit(closed,!mp->bobflag); + hushdex_extrafields(closed,msgjson); + hexstr = hushdex_submit(closed,!mp->bobflag); if ( (retjson= dpow_broadcast(SUBATOMIC_PRIORITY,hexstr,(char *)"inbox",(char *)"closed",senderpub,"","")) != 0 ) { if ( (mp->closedid= juint(retjson,"id")) != 0 ) retval = 1; - subatomic_status(mp,SUBATOMIC_CLOSED); + hushdex_status(mp,SUBATOMIC_CLOSED); printf("%u closedid.%u\n",mp->origid,mp->closedid); free_json(retjson); } @@ -912,25 +882,25 @@ int32_t subatomic_closed(struct msginfo *mp,cJSON *closed,cJSON *msgjson,char *s return(retval); } -uint32_t subatomic_alice_openrequest(struct msginfo *origmp) +uint32_t hushdex_alice_openrequest(struct msginfo *origmp) { struct msginfo *mp; cJSON *retjson,*openrequest; char *hexstr,*str,tmpstr[32]; - mp = subatomic_tracker(origmp->origid); + mp = hushdex_tracker(origmp->origid); mp->origid = origmp->origid; mp->rel.satoshis = origmp->rel.satoshis; mp->rel.istoken = origmp->rel.istoken; strcpy(mp->rel.tokenid,origmp->rel.tokenid); strcpy(mp->rel.name,origmp->rel.name); - strcpy(mp->rel.coin,subatomic_checkname(tmpstr,mp,1,origmp->rel.name)); + strcpy(mp->rel.coin,hushdex_checkname(tmpstr,mp,1,origmp->rel.name)); strcpy(mp->alice.pubkey,DPOW_pubkeystr); strcpy(mp->alice.secp,DPOW_secpkeystr); strcpy(mp->alice.recvZaddr,DPOW_recvZaddr); strcpy(mp->alice.recvaddr,DPOW_recvaddr); printf("rel.%s/%s %s openrequest %u status.%d (%s/%s)\n",mp->rel.name,mp->rel.coin,mp->rel.tokenid,mp->origid,mp->status,mp->alice.recvaddr,mp->alice.recvZaddr); - if ( mp->status == 0 && subatomic_orderbook_mpset(mp,"") != 0 ) + if ( mp->status == 0 && hushdex_orderbook_mpset(mp,"") != 0 ) { strcpy(mp->bob.pubkey,mp->senderpub); - if ( subatomic_zonly(&mp->base) != 0 || subatomic_zonly(&mp->rel) != 0 ) + if ( hushdex_zonly(&mp->base) != 0 || hushdex_zonly(&mp->rel) != 0 ) mp->OTCmode = 1; else mp->OTCmode = SUBATOMIC_OTCDEFAULT; strcpy(origmp->base.name,mp->base.name); @@ -948,14 +918,14 @@ uint32_t subatomic_alice_openrequest(struct msginfo *origmp) printf("%u cant do zaddr or fractional base %s.%s tokens %.8f\n",mp->origid,mp->base.coin,mp->base.tokenid,dstr(mp->base.satoshis)); return(0); } - else if ( (openrequest= subatomic_mpjson(mp)) != 0 ) + else if ( (openrequest= hushdex_mpjson(mp)) != 0 ) { - hexstr = subatomic_submit(openrequest,!mp->bobflag); + hexstr = hushdex_submit(openrequest,!mp->bobflag); if ( (retjson= dpow_broadcast(SUBATOMIC_PRIORITY,hexstr,(char *)"inbox",(char *)"openrequest",mp->bob.pubkey,"","")) != 0 ) { mp->openrequestid = juint(retjson,"id"); printf("%u openrequest.%u -> (%s)\n",mp->origid,mp->openrequestid,mp->bob.pubkey); - subatomic_status(mp,SUBATOMIC_OPENREQUEST); + hushdex_status(mp,SUBATOMIC_OPENREQUEST); free_json(retjson); } free(hexstr); @@ -964,15 +934,15 @@ uint32_t subatomic_alice_openrequest(struct msginfo *origmp) return(mp->openrequestid); } -void subatomic_bob_gotopenrequest(uint32_t inboxid,char *senderpub,cJSON *msgjson,char *basename,char *relname) +void hushdex_bob_gotopenrequest(uint32_t inboxid,char *senderpub,cJSON *msgjson,char *basename,char *relname) { struct msginfo *mp; cJSON *approval; int32_t origid; char *addr,tmpstr[32],*coin,*acname=""; origid = juint(msgjson,"origid"); - mp = subatomic_tracker(origid); + mp = hushdex_tracker(origid); strcpy(mp->base.name,basename); - strcpy(mp->base.coin,subatomic_checkname(tmpstr,mp,0,basename)); + strcpy(mp->base.coin,hushdex_checkname(tmpstr,mp,0,basename)); strcpy(mp->rel.name,relname); - strcpy(mp->rel.coin,subatomic_checkname(tmpstr,mp,1,relname)); + strcpy(mp->rel.coin,hushdex_checkname(tmpstr,mp,1,relname)); mp->origid = origid; mp->rel.satoshis = j64bits(msgjson,"relsatoshis"); mp->bobflag = 1; @@ -986,42 +956,42 @@ void subatomic_bob_gotopenrequest(uint32_t inboxid,char *senderpub,cJSON *msgjso strcpy(mp->alice.recvZaddr,addr); if ( (addr= jstr(msgjson,"alicesecp")) != 0 ) strcpy(mp->alice.secp,addr); - if ( subatomic_zonly(&mp->base) != 0 || subatomic_zonly(&mp->rel) != 0 ) + if ( hushdex_zonly(&mp->base) != 0 || hushdex_zonly(&mp->rel) != 0 ) mp->OTCmode = 1; else mp->OTCmode = SUBATOMIC_OTCDEFAULT; printf("%u got open request\n",mp->origid); - if ( mp->status == 0 && subatomic_orderbook_mpset(mp,basename) != 0 && (approval= subatomic_mpjson(mp)) != 0 ) + if ( mp->status == 0 && hushdex_orderbook_mpset(mp,basename) != 0 && (approval= hushdex_mpjson(mp)) != 0 ) { if ( mp->rel.istoken != 0 && ((mp->rel.satoshis % SATOSHIDEN) != 0 || mp->rel.iszaddr != 0) ) { printf("%u cant do zaddr or fractional rel %s.%s tokens %.8f\n",mp->origid,mp->rel.coin,mp->rel.tokenid,dstr(mp->rel.satoshis)); - subatomic_closed(mp,approval,msgjson,senderpub); + hushdex_closed(mp,approval,msgjson,senderpub); return; } else if ( mp->base.istoken != 0 && ((mp->base.satoshis % SATOSHIDEN) != 0 || mp->base.iszaddr != 0 ) ) { printf("%u cant do zaddr or fractional base %s.%s tokens %.8f\n",mp->origid,mp->base.coin,mp->base.tokenid,dstr(mp->base.satoshis)); - subatomic_closed(mp,approval,msgjson,senderpub); + hushdex_closed(mp,approval,msgjson,senderpub); return; } - else if ( subatomic_getbalance(&mp->base) < mp->base.satoshis ) + else if ( hushdex_getbalance(&mp->base) < mp->base.satoshis ) { - printf("%u bob node low on %s funds! %.8f not enough for %.8f\n",mp->origid,mp->base.coin,dstr(subatomic_getbalance(&mp->base)),dstr(mp->base.satoshis)); - subatomic_closed(mp,approval,msgjson,senderpub); + printf("%u bob node low on %s funds! %.8f not enough for %.8f\n",mp->origid,mp->base.coin,dstr(hushdex_getbalance(&mp->base)),dstr(mp->base.satoshis)); + hushdex_closed(mp,approval,msgjson,senderpub); } else { printf("%u bob (%s/%s) gotopenrequest origid.%u status.%d (%s/%s) SENDERPUB.(%s)\n",mp->origid,mp->base.name,mp->rel.name,mp->origid,mp->status,mp->bob.recvaddr,mp->bob.recvZaddr,senderpub); - subatomic_approved(mp,approval,msgjson,senderpub); + hushdex_approved(mp,approval,msgjson,senderpub); } } } -int32_t subatomic_channelapproved(uint32_t inboxid,char *senderpub,cJSON *msgjson,struct msginfo *origmp) +int32_t hushdex_channelapproved(uint32_t inboxid,char *senderpub,cJSON *msgjson,struct msginfo *origmp) { struct msginfo *mp; cJSON *approval; char *addr,*coin,*acname; int32_t retval = 0; - mp = subatomic_tracker(juint(msgjson,"origid")); - if ( subatomic_orderbook_mpset(mp,mp->base.name) != 0 && (approval= subatomic_mpjson(mp)) != 0 ) + mp = hushdex_tracker(juint(msgjson,"origid")); + if ( hushdex_orderbook_mpset(mp,mp->base.name) != 0 && (approval= hushdex_mpjson(mp)) != 0 ) { printf("%u iambob.%d (%s/%s) channelapproved origid.%u status.%d\n",mp->origid,mp->bobflag,mp->base.name,mp->rel.name,mp->origid,mp->status); if ( mp->bobflag == 0 && mp->status == SUBATOMIC_OPENREQUEST ) @@ -1032,46 +1002,46 @@ int32_t subatomic_channelapproved(uint32_t inboxid,char *senderpub,cJSON *msgjso strcpy(mp->bob.recvZaddr,addr); if ( (addr= jstr(msgjson,"bobsecp")) != 0 ) strcpy(mp->bob.secp,addr); - retval = subatomic_approved(mp,approval,msgjson,senderpub); + retval = hushdex_approved(mp,approval,msgjson,senderpub); } else if ( mp->bobflag != 0 && mp->status == SUBATOMIC_APPROVED ) - retval = subatomic_opened(mp,approval,msgjson,senderpub); + retval = hushdex_opened(mp,approval,msgjson,senderpub); } return(retval); } -int32_t subatomic_incomingopened(uint32_t inboxid,char *senderpub,cJSON *msgjson,struct msginfo *origmp) +int32_t hushdex_incomingopened(uint32_t inboxid,char *senderpub,cJSON *msgjson,struct msginfo *origmp) { struct msginfo *mp; cJSON *payment; int32_t retval = 0; - mp = subatomic_tracker(juint(msgjson,"origid")); - if ( subatomic_orderbook_mpset(mp,mp->base.name) != 0 && (payment= subatomic_mpjson(mp)) != 0 ) + mp = hushdex_tracker(juint(msgjson,"origid")); + if ( hushdex_orderbook_mpset(mp,mp->base.name) != 0 && (payment= hushdex_mpjson(mp)) != 0 ) { printf("%u iambob.%d (%s/%s) incomingchannel status.%d\n",mp->origid,mp->bobflag,mp->base.name,mp->rel.name,mp->status); if ( mp->bobflag == 0 && mp->status == SUBATOMIC_APPROVED ) - retval = subatomic_payment(mp,payment,msgjson,senderpub); + retval = hushdex_payment(mp,payment,msgjson,senderpub); else if ( mp->bobflag != 0 && mp->status == SUBATOMIC_OPENED ) retval = 1; // nothing to do } return(retval); } -int32_t subatomic_incomingpayment(uint32_t inboxid,char *senderpub,cJSON *msgjson,struct msginfo *origmp) +int32_t hushdex_incomingpayment(uint32_t inboxid,char *senderpub,cJSON *msgjson,struct msginfo *origmp) { static FILE *fp; struct msginfo *mp; cJSON *pay,*rawtx,*retjson; bits256 txid; char str[65],*hexstr; int32_t retval = 0; - mp = subatomic_tracker(juint(msgjson,"origid")); - if ( subatomic_orderbook_mpset(mp,mp->base.name) != 0 && (pay= subatomic_mpjson(mp)) != 0 ) + mp = hushdex_tracker(juint(msgjson,"origid")); + if ( hushdex_orderbook_mpset(mp,mp->base.name) != 0 && (pay= hushdex_mpjson(mp)) != 0 ) { printf("%u iambob.%d (%s/%s) incomingpayment status.%d\n",mp->origid,mp->bobflag,mp->base.name,mp->rel.name,mp->status); if ( mp->bobflag == 0 ) { txid = jbits256(msgjson,"bobpayment"); jaddbits256(msgjson,"alicepayment",mp->alicepayment); - printf("%u alice waits for %s.%s to be in mempool (%.8f -> %s)\n",mp->origid,mp->base.name,bits256_str(str,txid),dstr(mp->base.satoshis),subatomic_zonly(&mp->base) == 0 ? mp->alice.recvaddr : mp->alice.recvZaddr); + printf("%u alice waits for %s.%s to be in mempool (%.8f -> %s)\n",mp->origid,mp->base.name,bits256_str(str,txid),dstr(mp->base.satoshis),hushdex_zonly(&mp->base) == 0 ? mp->alice.recvaddr : mp->alice.recvZaddr); hexstr = jstr(msgjson,"bobtx"); - if ( (rawtx= subatomic_txidwait(&mp->base,txid,hexstr,SUBATOMIC_TIMEOUT,senderpub)) != 0 ) + if ( (rawtx= hushdex_txidwait(&mp->base,txid,hexstr,SUBATOMIC_TIMEOUT,senderpub)) != 0 ) { - if ( subatomic_verifypayment(&mp->base,rawtx,mp->base.satoshis,subatomic_zonly(&mp->base) == 0 ? mp->alice.recvaddr : mp->alice.recvZaddr,txid) >= 0 ) + if ( hushdex_verifypayment(&mp->base,rawtx,mp->base.satoshis,hushdex_zonly(&mp->base) == 0 ? mp->alice.recvaddr : mp->alice.recvZaddr,txid) >= 0 ) mp->gotpayment = 1; free_json(rawtx); } @@ -1103,28 +1073,28 @@ int32_t subatomic_incomingpayment(uint32_t inboxid,char *senderpub,cJSON *msgjso if ( (retjson= dpow_broadcast(SUBATOMIC_PRIORITY,bits256_str(str,mp->alicepayment),(char *)"incomplete",str,DPOW_pubkeystr,"","")) != 0 ) free_json(retjson); } - subatomic_closed(mp,pay,msgjson,senderpub); + hushdex_closed(mp,pay,msgjson,senderpub); exit(-1); } } if ( mp->gotpayment != 0 ) - retval = subatomic_paidinfull(mp,pay,msgjson,senderpub); + retval = hushdex_paidinfull(mp,pay,msgjson,senderpub); else { if ( mp->bobflag != 0 && mp->status == SUBATOMIC_OPENED ) { txid = jbits256(msgjson,"alicepayment"); - printf("%u bob waits for %s.%s to be in mempool (%.8f -> %s)\n",mp->origid,mp->rel.name,bits256_str(str,txid),dstr(mp->rel.satoshis),subatomic_zonly(&mp->rel) == 0 ? mp->bob.recvaddr : mp->bob.recvZaddr); + printf("%u bob waits for %s.%s to be in mempool (%.8f -> %s)\n",mp->origid,mp->rel.name,bits256_str(str,txid),dstr(mp->rel.satoshis),hushdex_zonly(&mp->rel) == 0 ? mp->bob.recvaddr : mp->bob.recvZaddr); hexstr = jstr(msgjson,"alicetx"); - if ( (rawtx= subatomic_txidwait(&mp->rel,txid,hexstr,SUBATOMIC_TIMEOUT,senderpub)) != 0 ) + if ( (rawtx= hushdex_txidwait(&mp->rel,txid,hexstr,SUBATOMIC_TIMEOUT,senderpub)) != 0 ) { - if ( subatomic_verifypayment(&mp->rel,rawtx,mp->rel.satoshis,subatomic_zonly(&mp->rel) == 0 ? mp->bob.recvaddr : mp->bob.recvZaddr,txid) >= 0 ) + if ( hushdex_verifypayment(&mp->rel,rawtx,mp->rel.satoshis,hushdex_zonly(&mp->rel) == 0 ? mp->bob.recvaddr : mp->bob.recvZaddr,txid) >= 0 ) mp->gotpayment = 1; free_json(rawtx); } if ( mp->gotpayment != 0 ) { - retval = subatomic_payment(mp,pay,msgjson,senderpub); + retval = hushdex_payment(mp,pay,msgjson,senderpub); jaddbits256(msgjson,"bobpayment",mp->bobpayment); if ( mp->rel.iszaddr == 0 ) { @@ -1151,42 +1121,42 @@ int32_t subatomic_incomingpayment(uint32_t inboxid,char *senderpub,cJSON *msgjso return(retval); } -int32_t subatomic_incomingfullypaid(uint32_t inboxid,char *senderpub,cJSON *msgjson,struct msginfo *origmp) +int32_t hushdex_incomingfullypaid(uint32_t inboxid,char *senderpub,cJSON *msgjson,struct msginfo *origmp) { struct msginfo *mp; cJSON *closed; int32_t retval = 0; - mp = subatomic_tracker(juint(msgjson,"origid")); - if ( subatomic_orderbook_mpset(mp,mp->base.name) != 0 && (closed= subatomic_mpjson(mp)) != 0 ) + mp = hushdex_tracker(juint(msgjson,"origid")); + if ( hushdex_orderbook_mpset(mp,mp->base.name) != 0 && (closed= hushdex_mpjson(mp)) != 0 ) { printf("%u iambob.%d (%s/%s) incomingfullypaid status.%d\n",mp->origid,mp->bobflag,mp->base.name,mp->rel.name,mp->status); // error check msgjson vs M if ( mp->bobflag == 0 && mp->status == SUBATOMIC_PAIDINFULL ) - retval = subatomic_closed(mp,closed,msgjson,senderpub); + retval = hushdex_closed(mp,closed,msgjson,senderpub); else if ( mp->bobflag != 0 && mp->status == SUBATOMIC_PAYMENT ) - retval = subatomic_paidinfull(mp,closed,msgjson,senderpub); + retval = hushdex_paidinfull(mp,closed,msgjson,senderpub); } return(retval); } -int32_t subatomic_incomingclosed(uint32_t inboxid,char *senderpub,cJSON *msgjson,struct msginfo *origmp) +int32_t hushdex_incomingclosed(uint32_t inboxid,char *senderpub,cJSON *msgjson,struct msginfo *origmp) { struct msginfo *mp; cJSON *closed; int32_t retval = 0; - mp = subatomic_tracker(juint(msgjson,"origid")); - if ( subatomic_orderbook_mpset(mp,mp->base.name) != 0 && (closed= subatomic_mpjson(mp)) != 0 ) + mp = hushdex_tracker(juint(msgjson,"origid")); + if ( hushdex_orderbook_mpset(mp,mp->base.name) != 0 && (closed= hushdex_mpjson(mp)) != 0 ) { printf("%u iambob.%d (%s/%s) incomingclose status.%d\n",mp->origid,mp->bobflag,mp->base.name,mp->rel.name,mp->status); if ( mp->bobflag != 0 ) dpow_cancel(mp->origid); if ( mp->status < SUBATOMIC_CLOSED ) { - retval = subatomic_closed(mp,closed,msgjson,senderpub); - subatomic_status(mp,SUBATOMIC_CLOSED); + retval = hushdex_closed(mp,closed,msgjson,senderpub); + hushdex_status(mp,SUBATOMIC_CLOSED); } retval = 1; } return(retval); } -int32_t subatomic_ismine(int32_t bobflag,cJSON *json,char *basename,char *relname) +int32_t hushdex_ismine(int32_t bobflag,cJSON *json,char *basename,char *relname) { char *base,*rel; if ( (base= jstr(json,"base")) != 0 && (rel= jstr(json,"rel")) != 0 ) @@ -1203,7 +1173,7 @@ int32_t subatomic_ismine(int32_t bobflag,cJSON *json,char *basename,char *relnam return(0); } -void subatomic_tokensregister(int32_t priority) +void hushdex_tokensregister(int32_t priority) { char *token_name,*tokenid,existing[65]; cJSON *tokens,*token; int32_t i,numtokens; if ( SUBATOMIC_json != 0 && (tokens= jarray(&numtokens,SUBATOMIC_json,"tokens")) != 0 ) @@ -1223,7 +1193,7 @@ void subatomic_tokensregister(int32_t priority) } } -void subatomic_filesregister(int32_t priority) +void hushdex_filesregister(int32_t priority) { char *fname,*tokenid,*coin,existing[512]; int64_t price; cJSON *files,*file,*prices; int32_t i,j,m,numfiles; if ( SUBATOMIC_json != 0 && (files= jarray(&numfiles,SUBATOMIC_json,"files")) != 0 ) @@ -1233,7 +1203,7 @@ void subatomic_filesregister(int32_t priority) file = jitem(files,i); if ( file != 0 ) { - // {"filename":"komodod",prices:[{"KMD":0.1}, {"PIRATE:1"}]} + // {"filename":"hushd",prices:[{"HUSH":1}, {"ZEC:1"}]} fname = jstr(file,"filename"); if ( (prices= jarray(&m,file,"prices")) != 0 && m > 0 ) { @@ -1251,12 +1221,12 @@ void subatomic_filesregister(int32_t priority) } } -void subatomic_loop(struct msginfo *mp) +void hushdex_loop(struct msginfo *mp) { static char *tagBs[] = { "openrequest", "approved", "opened", "payment", "paid", "closed" }; static uint32_t stopats[sizeof(tagBs)/sizeof(*tagBs)]; struct inboxinfo **ptrs,*ptr; char *tagB; int32_t i,iter,n,msgs=0,mask=0; cJSON *inboxjson; - fprintf(stderr,"start subatomic_loop iambob.%d %s -> %s, %u %llu %u\n",mp->bobflag,mp->base.name,mp->rel.name,mp->origid,(long long)mp->rel.satoshis,mp->openrequestid); + fprintf(stderr,"start hushdex_loop iambob.%d %s -> %s, %u %llu %u\n",mp->bobflag,mp->base.name,mp->rel.name,mp->origid,(long long)mp->rel.satoshis,mp->openrequestid); while ( 1 ) { if ( msgs == 0 ) @@ -1266,8 +1236,8 @@ void subatomic_loop(struct msginfo *mp) if ( mp->bobflag != 0 ) { dpow_pubkeyregister(SUBATOMIC_PRIORITY); - subatomic_tokensregister(SUBATOMIC_PRIORITY); - subatomic_filesregister(SUBATOMIC_PRIORITY); + hushdex_tokensregister(SUBATOMIC_PRIORITY); + hushdex_filesregister(SUBATOMIC_PRIORITY); } } msgs = 0; @@ -1285,24 +1255,24 @@ void subatomic_loop(struct msginfo *mp) { if ( jint(inboxjson,"tobob") != mp->bobflag ) continue; - if ( subatomic_ismine(mp->bobflag,inboxjson,mp->base.name,mp->rel.name) != 0 ) + if ( hushdex_ismine(mp->bobflag,inboxjson,mp->base.name,mp->rel.name) != 0 ) { if ( strcmp(tagB,"openrequest") == 0 && mp->bobflag != 0 ) - subatomic_bob_gotopenrequest(ptr->shorthash,ptr->senderpub,inboxjson,mp->base.name,mp->rel.name); + hushdex_bob_gotopenrequest(ptr->shorthash,ptr->senderpub,inboxjson,mp->base.name,mp->rel.name); else if ( strcmp(tagB,"approved") == 0 ) - mask |= subatomic_channelapproved(ptr->shorthash,ptr->senderpub,inboxjson,mp) << 0; + mask |= hushdex_channelapproved(ptr->shorthash,ptr->senderpub,inboxjson,mp) << 0; else if ( strcmp(tagB,"opened") == 0 ) - mask |= subatomic_incomingopened(ptr->shorthash,ptr->senderpub,inboxjson,mp) << 1; + mask |= hushdex_incomingopened(ptr->shorthash,ptr->senderpub,inboxjson,mp) << 1; else if ( strcmp(tagB,"payment") == 0 ) - mask |= subatomic_incomingpayment(ptr->shorthash,ptr->senderpub,inboxjson,mp) << 2; + mask |= hushdex_incomingpayment(ptr->shorthash,ptr->senderpub,inboxjson,mp) << 2; else if ( strcmp(tagB,"paid") == 0 ) - mask |= subatomic_incomingfullypaid(ptr->shorthash,ptr->senderpub,inboxjson,mp) << 3; + mask |= hushdex_incomingfullypaid(ptr->shorthash,ptr->senderpub,inboxjson,mp) << 3; else if ( strcmp(tagB,"closed") == 0 ) - mask |= subatomic_incomingclosed(ptr->shorthash,ptr->senderpub,inboxjson,mp) * 0x1f; + mask |= hushdex_incomingclosed(ptr->shorthash,ptr->senderpub,inboxjson,mp) * 0x1f; else fprintf(stderr,"iambob.%d unknown unexpected tagB.(%s)\n",mp->bobflag,tagB); } free_json(inboxjson); - } else fprintf(stderr,"subatomic iambob.%d loop got unparseable(%s)\n",mp->bobflag,ptr->jsonstr); + } else fprintf(stderr,"hushdex iambob.%d loop got unparseable(%s)\n",mp->bobflag,ptr->jsonstr); free(ptr); ptrs[i] = 0; } @@ -1320,40 +1290,36 @@ void subatomic_loop(struct msginfo *mp) int32_t main(int32_t argc,char **argv) { - char *fname = "subatomic.json"; - int32_t i,height; char *coin,*kcli,*subatomic,*hashstr,*acname=(char *)""; cJSON *retjson; bits256 blockhash; char checkstr[65],str[65],str2[65],tmpstr[32]; long fsize; struct msginfo M; + char *fname = "hushdex.json"; + int32_t i,height; char *coin,*kcli,*hushdex,*hashstr,*acname=(char *)""; cJSON *retjson; bits256 blockhash; char checkstr[65],str[65],str2[65],tmpstr[32]; long fsize; struct msginfo M; memset(&M,0,sizeof(M)); srand((int32_t)time(NULL)); - if ( (subatomic= filestr(&fsize,fname)) == 0 ) + if ( (hushdex= filestr(&fsize,fname)) == 0 ) { fprintf(stderr,"cant load %s file\n",fname); exit(-1); } - if ( (SUBATOMIC_json= cJSON_Parse(subatomic)) == 0 ) + if ( (SUBATOMIC_json= cJSON_Parse(hushdex)) == 0 ) { - fprintf(stderr,"cant parse subatomic.json file (%s)\n",subatomic); + fprintf(stderr,"cant parse hushdex.json file (%s)\n",hushdex); exit(-1); } - free(subatomic); + free(hushdex); if ( argc >= 4 ) { if ( dpow_pubkey() < 0 ) { - fprintf(stderr,"couldnt set pubkey for DEX\n"); + fprintf(stderr,"couldnt set pubkey for ZEX\n"); return(-1); } coin = (char *)argv[1]; - if ( argv[2][0] != 0 ) + if ( argv[2][0] != 0 ) { REFCOIN_CLI = (char *)argv[2]; - else - { - if ( strcmp(coin,"KMD") != 0 ) - { - acname = coin; - } + } else { + acname = coin; } hashstr = (char *)argv[3]; - strcpy(M.rel.coin,subatomic_checkname(tmpstr,&M,1,coin)); + strcpy(M.rel.coin,hushdex_checkname(tmpstr,&M,1,coin)); strcpy(M.rel.name,coin); if ( argc == 4 && strlen(hashstr) == 64 ) // for blocknotify usage, seems not needed { @@ -1404,24 +1370,24 @@ int32_t main(int32_t argc,char **argv) mult = SATOSHIDEN; break; } - if ( subatomic_getbalance(&M.rel) < M.rel.satoshis/mult ) + if ( hushdex_getbalance(&M.rel) < M.rel.satoshis/mult ) { - fprintf(stderr,"not enough balance %s %.8f for %.8f\n",M.rel.coin,dstr(subatomic_getbalance(&M.rel)),dstr(M.rel.satoshis/mult)); + fprintf(stderr,"not enough balance %s %.8f for %.8f\n",M.rel.coin,dstr(hushdex_getbalance(&M.rel)),dstr(M.rel.satoshis/mult)); return(-1); } - fprintf(stderr,"subatomic_channel_alice (%s/%s) %s %u with %.8f %llu\n",M.rel.name,M.rel.coin,hashstr,M.origid,atof(argv[4]),(long long)M.rel.satoshis); + fprintf(stderr,"hushdex_channel_alice (%s/%s) %s %u with %.8f %llu\n",M.rel.name,M.rel.coin,hashstr,M.origid,atof(argv[4]),(long long)M.rel.satoshis); dpow_pubkeyregister(SUBATOMIC_PRIORITY); - M.openrequestid = subatomic_alice_openrequest(&M); + M.openrequestid = hushdex_alice_openrequest(&M); if ( M.openrequestid != 0 ) - subatomic_loop(&M); + hushdex_loop(&M); } else fprintf(stderr,"checkstr mismatch %s %s != %s\n",coin,hashstr,checkstr); } else { M.bobflag = 1; strcpy(M.base.name,hashstr); - strcpy(M.base.coin,subatomic_checkname(tmpstr,&M,0,hashstr)); - subatomic_loop(&M); // while ( 1 ) loop for each relcoin -> basecoin + strcpy(M.base.coin,hushdex_checkname(tmpstr,&M,0,hashstr)); + hushdex_loop(&M); // while ( 1 ) loop for each relcoin -> basecoin } } return(SUBATOMIC_retval); diff --git a/src/cc/dapps/hushdex.json b/src/cc/dapps/hushdex.json new file mode 100644 index 000000000..dbb7df058 --- /dev/null +++ b/src/cc/dapps/hushdex.json @@ -0,0 +1,19 @@ +{ +"authorized": [ + {"dukeleto":"030554bffcf6dfcb34a20c486ff0a5be5546b9cc16fba969216527263f8e98c4af" }, + {"gilardh":"020554bffcf6dfcb34a20c486ff5a5be5546b9cc06fba9692165272b3f8e98c448" }, + {"nhdigitalcash":"030554bffcf6dfcb34a20c086ff5a5be5546b9cc16fba9692105272b3f8e98c4a0" }, + {"miodrag":"02b25de3ee5335518b06f69f4fbabb029cfc737603b100996841d5532b324a5a61" } +], +"tokens":[ +], +"files":[ + {"filename":"hushd","prices":[{"HUSH":0.1}, {"ZEC":1}]} +], +"externalcoins":[ + { "BTC":"bitcoin-cli" }, + { "HUSH":"hush-cli" }, + { "ZEC":"zcash-cli" } +] +} + diff --git a/src/cc/dapps/oraclefeed.c b/src/cc/dapps/oraclefeed.c deleted file mode 100644 index ac1f88400..000000000 --- a/src/cc/dapps/oraclefeed.c +++ /dev/null @@ -1,1151 +0,0 @@ -/****************************************************************************** - * 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 -#include -#include -#include "cJSON.c" - -bits256 zeroid; - -void myprintf(const char* format, ...) -{ - va_list marker; - va_start( marker, format ); - vfprintf(stdout, format, marker); - fflush(stdout); - va_end( marker ); -} - -char hexbyte(int32_t c) -{ - c &= 0xf; - if ( c < 10 ) - return('0'+c); - else if ( c < 16 ) - return('a'+c-10); - else return(0); -} - -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 ) - { - //myprintf("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(unsigned char *bytes,int32_t n,char *hex) -{ - int32_t adjust,i = 0; - //myprintf("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 ( 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]); - myprintf("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); - //myprintf("i.%d (%02x) [%c%c]\n",i,message[i],hexbytes[i*2],hexbytes[i*2+1]); - } - hexbytes[len*2] = 0; - //myprintf("len.%ld\n",len*2+1); - return((int32_t)len*2+1); -} - -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) - { - myprintf("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); -} - -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; i0; 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; - //myprintf("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 ) - myprintf("Null buf ???\n"); - else - { - if ( fread(buf,1,(long)filesize,fp) != (unsigned long)filesize ) - myprintf("error reading filesize.%ld\n",(long)filesize); - buf[filesize] = 0; - } - fclose(fp); - *lenp = filesize; - //myprintf("loaded.(%s)\n",buf); - } //else myprintf("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)); -} - -cJSON *get_urljson(char *url,char *fname) -{ - char *jsonstr; cJSON *json = 0; - if ( (jsonstr= send_curl(url,fname)) != 0 ) - { - //myprintf("(%s) -> (%s)\n",url,jsonstr); - json = cJSON_Parse(jsonstr); - free(jsonstr); - } - return(json); -} - -////////////////////////////////////////////// -// start of dapp -////////////////////////////////////////////// - -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 ( (bpi= jobj(pjson,"bpi")) != 0 && (usd= jobj(bpi,"USD")) != 0 ) - { - btcusd = jdouble(usd,"rate_float") * SATOSHIDEN; - myprintf("BTC/USD %.4f\n",dstr(btcusd)); - } - free_json(pjson); - } - return(btcusd); -} - -char *REFCOIN_CLI; - -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 ) - myprintf("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 ( 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); - //myprintf("ref.(%s) REFCOIN_CLI (%s)\n",refcoin,cmdstr); - } -#ifdef TESTMODE - fprintf(stderr,"cmd: %s\n",cmdstr); -#endif // TESTMODE - system(cmdstr); - *retstrp = 0; - if ( (jsonstr= filestr(&fsize,fname)) != 0 ) - { - jsonstr[strlen(jsonstr)-1]='\0'; -#ifdef TESTMODE - fprintf(stderr,"jsonstr.(%s)\n",jsonstr); -#endif // TESTMODE - 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); -} - -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_cli(refcoin,&retstr,acname,"sendrawtransaction",hexstr,"","","")) != 0 ) - { - if (strcmp("error",jstr(retjson,"result"))==0) myprintf("%s\n",jstr(retjson,"error")); - free_json(retjson); - } - else if ( retstr != 0 ) - { - if ( strlen(retstr) >= 64 ) - { - retstr[64] = 0; - decode_hex(txid.bytes,32,retstr); - } - fprintf(stderr,"broadcast %s txid.(%s)\n",strlen(acname)>0?acname:refcoin,bits256_str(str,txid)); - free(retstr); - } - } - return(txid); -} - -int32_t get_coinheight(char *refcoin,char *acname) -{ - cJSON *retjson; char *retstr; int32_t height=0; - if ( (retjson= get_cli(refcoin,&retstr,acname,"getblockchaininfo","","","","")) != 0 ) - { - height = jint(retjson,"blocks"); - free_json(retjson); - - } - else if ( retstr != 0 ) - { - fprintf(stderr,"%s get_coinheight.(%s) error.(%s)\n",refcoin,acname,retstr); - free(retstr); - } - return(height); -} - -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_cli(refcoin,&retstr,acname,"getblockhash",heightstr,"","","")) != 0 ) - { - fprintf(stderr,"unexpected blockhash json.(%s)\n",jprint(retjson,0)); - free_json(retjson); - } - else if ( retstr != 0 ) - { - if ( strlen(retstr) >= 64 ) - { - retstr[64] = 0; - decode_hex(hash.bytes,32,retstr); - } - free(retstr); - } - return(hash); -} - -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_cli(refcoin,&retstr,acname,"getblockheader",bits256_str(str,blockhash),"","","")) != 0 ) - { - merkleroot = jbits256(retjson,"merkleroot"); - //fprintf(stderr,"got merkleroot.(%s)\n",bits256_str(str,merkleroot)); - free_json(retjson); - } - else if ( retstr != 0 ) - { - fprintf(stderr,"%s %s get_coinmerkleroot error.(%s)\n",refcoin,acname,retstr); - free(retstr); - } - return(merkleroot); -} - -int32_t get_coinheader(char *refcoin,char *acname,bits256 *blockhashp,bits256 *merklerootp,int32_t prevheight) -{ - int32_t height = 0; char str[65]; - if ( prevheight == 0 ) - height = get_coinheight(refcoin,acname) - 20; - else height = prevheight + 1; - if ( height > 0 ) - { - *blockhashp = get_coinblockhash(refcoin,acname,height); - if ( bits256_nonz(*blockhashp) != 0 ) - { - *merklerootp = get_coinmerkleroot(refcoin,acname,*blockhashp); - if ( bits256_nonz(*merklerootp) != 0 ) - return(height); - } - } - memset(blockhashp,0,sizeof(*blockhashp)); - memset(merklerootp,0,sizeof(*merklerootp)); - return(0); -} - -cJSON *get_gatewayspending(int8_t type,char *refcoin,char *acname,char *bindtxidstr) -{ - 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 ) - { - //myprintf("pending.(%s)\n",jprint(retjson,0)); - return(retjson); - } - else if ( retstr != 0 ) - { - fprintf(stderr,"%s get_gatewayspending.(%s) error.(%s)\n",refcoin,acname,retstr); - free(retstr); - } - return(0); -} - -cJSON *get_gatewaysprocessed(int8_t type,char *refcoin,char *acname,char *bindtxidstr) -{ - cJSON *retjson; char *retstr; - 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 ) - { - //myprintf("pending.(%s)\n",jprint(retjson,0)); - return(retjson); - } - else if ( retstr != 0 ) - { - fprintf(stderr,"%s get_gatewaysprocessed.(%s) error.(%s)\n",refcoin,acname,retstr); - free(retstr); - } - return(0); -} - -cJSON *get_rawmempool(char *refcoin,char *acname) -{ - cJSON *retjson; char *retstr; - if ( (retjson= get_cli(refcoin,&retstr,acname,"getrawmempool","","","","")) != 0 ) - { - //myprintf("mempool.(%s)\n",jprint(retjson,0)); - return(retjson); - } - else if ( retstr != 0 ) - { - fprintf(stderr,"get_rawmempool.(%s) error.(%s)\n",acname,retstr); - free(retstr); - } - return(0); -} - -cJSON *get_addressutxos(char *refcoin,char *acname,char *coinaddr) -{ - cJSON *retjson; char *retstr,jsonbuf[256]; - if ( refcoin[0] != 0 && strcmp(refcoin,"KMD") != 0 ) - myprintf("warning: assumes %s has addressindex enabled\n",refcoin); - sprintf(jsonbuf,"{\\\"addresses\\\":[\\\"%s\\\"]}",coinaddr); - if ( (retjson= get_cli(refcoin,&retstr,acname,"getaddressutxos",jsonbuf,"","","")) != 0 ) - { - //myprintf("addressutxos.(%s)\n",jprint(retjson,0)); - return(retjson); - } - else if ( retstr != 0 ) - { - //fprintf(stderr,"get_addressutxos.(%s) error.(%s)\n",acname,retstr); - free(retstr); - } - return(0); -} - -cJSON *get_rawtransaction(char *refcoin,char *acname,bits256 txid) -{ - cJSON *retjson; char *retstr,str[65]; - if ( (retjson= get_cli(refcoin,&retstr,acname,"getrawtransaction",bits256_str(str,txid),"1","","")) != 0 ) - { - return(retjson); - } - else if ( retstr != 0 ) - { - fprintf(stderr,"get_rawtransaction.(%s) %s error.(%s)\n",refcoin,acname,retstr); - free(retstr); - } - return(0); -} - -int32_t validateaddress(char *refcoin,char *acname,char *depositaddr, char* compare) -{ - cJSON *retjson; char *retstr; int32_t res=0; - if ( (retjson= get_cli(refcoin,&retstr,acname,"validateaddress",depositaddr,"","","")) != 0 ) - { - 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); - } - - return (res); -} - -void importaddress(char *refcoin,char *acname,char *depositaddr, char *label,int rescan) -{ - cJSON *retjson; char *retstr; char rescanstr[10]; - if (rescan) strcpy(rescanstr,"true"); - else strcpy(rescanstr,"false"); - if ( (retjson= get_cli(refcoin,&retstr,acname,"importaddress",depositaddr,label,rescanstr,"")) != 0 ) - { - myprintf("importaddress.(%s)\n",jprint(retjson,0)); - free_json(retjson); - } - else if ( retstr != 0 ) - { - fprintf(stderr,"importaddress.(%s) %s error.(%s)\n",refcoin,acname,retstr); - free(retstr); - } -} - -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_cli(refcoin,&retstr,acname,"addmultisigaddress",Mstr,pubkeys,"","")) != 0 ) - { - fprintf(stderr,"unexpected addmultisigaddress json.(%s)\n",jprint(retjson,0)); - free(retstr); - } - else if ( retstr != 0 ) - { - sprintf(addr,"\"%s\"",retstr); - get_cli(refcoin,&retstr,acname,"importaddress",addr,"\"\"","false",""); - myprintf("addmultisigaddress.(%s)\n",retstr); - free_json(retjson); - } -} - -cJSON *getinputarray(int64_t *totalp,cJSON *unspents,int64_t required) -{ - cJSON *vin,*item,*vins = cJSON_CreateArray(); int32_t i,j=0,n,v; int64_t satoshis; bits256 txid; - *totalp = 0; - if ( (n= cJSON_GetArraySize(unspents)) > 0 ) - { - for (i=0; i= required ) - { - if (j<3) j++; - else break; - } - } - } - } - return(vins); -} - -char *createrawtx(char *refcoin,char *acname,char *depositaddr,char *withdrawaddr,char *txidaddr,int64_t satoshis) -{ - char *retstr,*retstr2,array[128],*txstr = 0; cJSON *retjson2,*retjson,*vins,*vouts; int64_t txfee,total,change = 0; - if ( strcmp(refcoin,"BTC") == 0 ) - txfee = 20000; - else txfee = 10000; - if ( satoshis < txfee ) - { - myprintf("createrawtx: satoshis %.8f < txfee %.8f\n",(double)satoshis/SATOSHIDEN,(double)txfee/SATOSHIDEN); - return(0); - } - sprintf(array,"\'[\"%s\"]\'",depositaddr); - 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 ) - { - if ( total >= satoshis ) - { - vouts = cJSON_CreateObject(); - jaddnum(vouts,withdrawaddr,(double)(satoshis-2*txfee)/SATOSHIDEN); - jaddnum(vouts,txidaddr,(double)txfee/SATOSHIDEN); - if ( total > satoshis) - { - change = (total - satoshis); - jaddnum(vouts,depositaddr,(double)change/SATOSHIDEN); - } - char *tmpA=jprint(vins,1); - char *tmpB=jprint(vouts,1); - char *argA=malloc(sizeof(char) * (strlen(tmpA)+3)); - char *argB=malloc(sizeof(char) * (strlen(tmpB)+3)); - sprintf(argA,"\'%s\'",tmpA); - sprintf(argB,"\'%s\'",tmpB); - if ( (retjson2= get_cli(refcoin,&txstr,acname,"createrawtransaction",argA,argB,"","")) != 0 ) - { - myprintf("createrawtx: unexpected JSON2.(%s)\n",jprint(retjson2,0)); - free_json(retjson2); - } - else if ( txstr == 0 ) - myprintf("createrawtx: null txstr and JSON2\n"); - free(tmpA); - free(tmpB); - free(argA); - free(argB); - } - else myprintf("not enough funds to create withdraw tx\n"); - } - free_json(retjson); - } - else if ( retstr != 0 ) - { - myprintf("createrawtx: unexpected null JSON, retstr.(%s)\n",retstr); - free(retstr); - } - else myprintf("createrawtx: null retstr and JSON\n"); - return(txstr); -} - -cJSON *addsignature(char *refcoin,char *acname,char *rawtx, int M) -{ - char *retstr,*hexstr; cJSON *retjson; - if ( (retjson= get_cli(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) + (M*2) + 1) - { - jaddnum(retjson,"partialtx",1); - return(retjson); - } - free_json(retjson); - } - else if ( retstr != 0 ) - { - myprintf("error parsing signrawtransaction.(%s)\n",retstr); - free(retstr); - } - return(0); -} - -bits256 gatewayspartialsign(int8_t type,char *refcoin,char *acname,bits256 txid,char *hex) -{ - 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 myprintf("%s\n",jstr(retjson,"error")); - free(retjson); - return (txid); - } - else if ( retstr != 0 ) - { - myprintf("error parsing gatewayspartialsing.(%s)\n",retstr); - free(retstr); - } - return (zeroid); -} - -bits256 gatewayscompletesigning(int8_t type,char *refcoin,char *acname,bits256 withtxid,char *hex) -{ - 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 myprintf("%s\n",jstr(retjson,"error")); - free(retjson); - return (txid); - } - else if ( retstr != 0 ) - { - myprintf("error parsing gatewayscompletesigning.(%s)\n",retstr); - free(retstr); - } - return (zeroid); -} - -bits256 gatewaysmarkdone(int8_t type,char *refcoin,char *acname,bits256 withtxid) -{ - 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 myprintf("%s\n",jstr(retjson,"error")); - free(retjson); - return (txid); - } - else if ( retstr != 0 ) - { - myprintf("error parsing gatewaysmarkdone.(%s)\n",retstr); - free(retstr); - } - return (zeroid); -} - -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; 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 ) - { - strcpy(depositaddr,deposit); - if ( jstr(retjson,"coin") != 0 && strcmp(jstr(retjson,"coin"),coin) == 0 && jint(retjson,"N") >= 1 ) - { - *Mp = jint(retjson,"M"); - *Np = jint(retjson,"N"); - } - else myprintf("coin.%s vs %s\n",jstr(retjson,"coin"),coin); - if ((pubarray=jarray(&n,retjson,"pubkeys"))!=0) - { - *pubkeys=malloc((sizeof(char)*70*n)+64); - sprintf(*pubkeys,"\"["); - for (int i=0;i 0 ) - { - num = 1; - break; - } - } - } - free_json(array); - } - } - return(num); - -} - -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 - // if txidaddr exists properly, spend the marker (txid.2) - // create withdraw tx and sign it - /// 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],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(type,refcoin,acname,bindtxidstr)) != 0 ) - { - if ( jint(retjson,"queueflag") != 0 && (coinstr= jstr(retjson,"coin")) != 0 && strcmp(coinstr,refcoin) == 0 ) - { - if ( (pending= jarray(&n,retjson,"pending")) != 0 ) - { - for (i=0; i> (i*8)) & 0xff)); - hexstr[16] = 0; - return(16); - } - } - else if ( strcmp(format,"Ihh") == 0 ) - { - if ( (height= get_coinheader(refcoin,acname,&blockhash,&merkleroot,prevheight)) > prevheight ) - { - for (i=0; i<4; i++) - sprintf(&hexstr[i*2],"%02x",(uint8_t)((height >> (i*8)) & 0xff)); - for (i=31; i>=0; i--) - sprintf(&hexstr[8 + (31-i)*2],"%02x",blockhash.bytes[i]); - for (i=31; i>=0; i--) - sprintf(&hexstr[8 + 64 + (31-i)*2],"%02x",merkleroot.bytes[i]); - hexstr[8 + 64*2] = 0; - return(height); - } - } - return(0); -} - -/* - oraclescreate "BTCUSD" "coindeskpricedata" "L" -> 4895f631316a649e216153aee7a574bd281686265dc4e8d37597f72353facac3 - oraclesregister 4895f631316a649e216153aee7a574bd281686265dc4e8d37597f72353facac3 1000000 -> 11c54d4ab17293217276396e27d86f714576ff55a3300dac34417047825edf93 - oraclessubscribe 4895f631316a649e216153aee7a574bd281686265dc4e8d37597f72353facac3 02ebc786cb83de8dc3922ab83c21f3f8a2f3216940c3bf9da43ce39e2a3a882c92 1.5 -> ce4e4afa53765b11a74543dacbd3174a93f33f12bb94cdc080c2c023726b5838 - oraclesdata 4895f631316a649e216153aee7a574bd281686265dc4e8d37597f72353facac3 000000ff00000000 -> e8a8c897e97389dcac31d81b617ab73a829110bd5c6f99f9f533b9c0e22700d0 - oraclessamples 4895f631316a649e216153aee7a574bd281686265dc4e8d37597f72353facac3 90ff8813a93b5b2615ec43974ff4fc91e4373dfd672d995676c43ff2dcda1010 10 -> -{ -"result": "success", -"samples": [ - [ - "4278190080" - ] - ] -} - -oraclescreate test testsformat s -> 17a841a919c284cea8a676f34e793da002e606f19a9258a3190bed12d5aaa3ff -oraclesregister -> 7825ad75ba854ab12868f7d2e06b4061903687fe93f41a2a99202a6b9ca3c029 -oraclessubscribe 17a841a919c284cea8a676f34e793da002e606f19a9258a3190bed12d5aaa3ff 02ebc786cb83de8dc3922ab83c21f3f8a2f3216940c3bf9da43ce39e2a3a882c92 1.5 -> faf8a6676f6389abad9e7f397015d200395c9f8a24c4ded291d83e6265b2f4d1 -oraclesdata 17a841a919c284cea8a676f34e793da002e606f19a9258a3190bed12d5aaa3ff 03404040 -> e8a8c897e97389dcac31d81b617ab73a829110bd5c6f99f9f533b9c0e22700d0 - -*/ - -// ./a.out AT5 1f1aefcca2bdea8196cfd77337fb21de22d200ddea977c2f9e8742c55829d808 02ebc786cb83de8dc3922ab83c21f3f8a2f3216940c3bf9da43ce39e2a3a882c92 Ihh e6c99f79d4afb216aa8063658b4222edb773dd24bb0f8e91bd4ef341f3e47e5e - -int32_t main(int32_t argc,char **argv) -{ - 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 ) - { - myprintf("usage: oraclefeed $ACNAME $ORACLETXID $MYPUBKEY $FORMAT $BINDTXID [refcoin_cli]\n"); - return(-1); - } - myprintf("Powered by CoinDesk (%s) %.8f\n","https://www.coindesk.com/price/",dstr(get_btcusd())); - acname = argv[1]; - oraclestr = argv[2]; - pkstr = argv[3]; - format = argv[4]; - bindtxidstr = argv[5]; - if ( argc > 6 ) - REFCOIN_CLI = argv[6]; - else REFCOIN_CLI = "./komodo-cli"; - if ( strncmp(format,"Ihh",3) != 0 && format[0] != 'L' ) - { - myprintf("only formats of L and Ihh are supported now\n"); - return(-1); - } - M = N = 0; - refcoin[0] = 0; - while ( 1 ) - { - retstr = 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 ) - { - strcpy(refcoin,jstr(clijson,"name")); - if ( strcmp("KMD",refcoin) != 0 && argc != 7 ) - { - myprintf("need to specify path to refcoin's cli as last argv\n"); - exit(0); - } - 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 - { - myprintf("cant find bindtxid.(%s)\n",bindtxidstr); - exit(0); - } - if (validateaddress(refcoin,"",depositaddr,"iswatchonly")==0 && validateaddress(refcoin,"",depositaddr,"ismine")==0) - { - if (M==1 && N==1) importaddress(refcoin,"",depositaddr,bindtxidstr,0); - else addmultisigaddress(refcoin,"",M,pubkeys); - } - if (pubkeys!=0) free(pubkeys); - myprintf("set refcoin %s <- %s [%s] M.%d of N.%d\n",depositaddr,refcoin,REFCOIN_CLI,M,N); - } - if ( (regjson= jarray(&n,clijson,"registered")) != 0 ) - { - for (i=0; i> 3) * 2 + 1],uint8_t hash[256 >> 3],uint8_ void vcalc_sha256cat(uint8_t hash[256 >> 3],uint8_t *src,int32_t len,uint8_t *src2,int32_t len2); void vupdate_sha256(uint8_t hash[256 >> 3],struct sha256_vstate *state,uint8_t *src,int32_t len); bits256 curve25519_shared(bits256 privkey,bits256 otherpub); -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); +int32_t dragon_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp); +int32_t dragon_rwbignum(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *endianedp); uint32_t calc_crc32(uint32_t crc,const void *buf,size_t size); uint64_t conv_NXTpassword(unsigned char *mysecret,unsigned char *mypublic,uint8_t *pass,int32_t passlen); diff --git a/src/cc/oracles.cpp b/src/cc/oracles.cpp index 61e5c9619..3ec5a0935 100644 --- a/src/cc/oracles.cpp +++ b/src/cc/oracles.cpp @@ -384,7 +384,7 @@ int32_t oracle_format(uint256 *hashp,int64_t *valp,char *str,uint8_t fmt,uint8_t { if ( len == 32 ) { - iguana_rwbignum(0,&data[offset],len,(uint8_t *)hashp); + dragon_rwbignum(0,&data[offset],len,(uint8_t *)hashp); if ( str != 0 ) sprintf(str,"%s",uint256_str(_str,*hashp)); } @@ -395,9 +395,9 @@ int32_t oracle_format(uint256 *hashp,int64_t *valp,char *str,uint8_t fmt,uint8_t switch ( len ) { case 1: val = (int8_t)data[offset]; break; - case 2: iguana_rwnum(0,&data[offset],len,(void *)&val16); val = val16; break; - case 4: iguana_rwnum(0,&data[offset],len,(void *)&val32); val = val32; break; - case 8: iguana_rwnum(0,&data[offset],len,(void *)&val); break; + case 2: dragon_rwnum(0,&data[offset],len,(void *)&val16); val = val16; break; + case 4: dragon_rwnum(0,&data[offset],len,(void *)&val32); val = val32; break; + case 8: dragon_rwnum(0,&data[offset],len,(void *)&val); break; } if ( str != 0 ) sprintf(str,"%lld",(long long)val); @@ -408,9 +408,9 @@ int32_t oracle_format(uint256 *hashp,int64_t *valp,char *str,uint8_t fmt,uint8_t switch ( len ) { case 1: uval = data[offset]; break; - case 2: iguana_rwnum(0,&data[offset],len,(void *)&uval16); uval = uval16; break; - case 4: iguana_rwnum(0,&data[offset],len,(void *)&uval32); uval = uval32; break; - case 8: iguana_rwnum(0,&data[offset],len,(void *)&uval); break; + case 2: dragon_rwnum(0,&data[offset],len,(void *)&uval16); uval = uval16; break; + case 4: dragon_rwnum(0,&data[offset],len,(void *)&uval32); uval = uval32; break; + case 8: dragon_rwnum(0,&data[offset],len,(void *)&uval); break; } if ( str != 0 ) sprintf(str,"%llu",(long long)uval); diff --git a/src/fiat-cli b/src/fiat-cli deleted file mode 100755 index 49332696a..000000000 --- a/src/fiat-cli +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -args="$@" -komodo_cli='./komodo-cli' - -./listassetchains | while read chain; do - echo $chain - $komodo_cli --ac_name=$chain $args -done diff --git a/src/fiat/axo b/src/fiat/axo deleted file mode 100755 index 18d38cac0..000000000 --- a/src/fiat/axo +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=AXO $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/beer b/src/fiat/beer deleted file mode 100755 index 34317bb93..000000000 --- a/src/fiat/beer +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=BEER $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/bet b/src/fiat/bet deleted file mode 100755 index ed99ce59f..000000000 --- a/src/fiat/bet +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=BET $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/bntn b/src/fiat/bntn deleted file mode 100755 index 7ae6f4e8d..000000000 --- a/src/fiat/bntn +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=BNTN $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/bots b/src/fiat/bots deleted file mode 100755 index 15c0fc288..000000000 --- a/src/fiat/bots +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=BOTS $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/btch b/src/fiat/btch deleted file mode 100755 index 6a57ea8d1..000000000 --- a/src/fiat/btch +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=BTCH $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/ccl b/src/fiat/ccl deleted file mode 100755 index c3d03a0a4..000000000 --- a/src/fiat/ccl +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=CCL $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/ceal b/src/fiat/ceal deleted file mode 100755 index 0cbeba67b..000000000 --- a/src/fiat/ceal +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=CEAL $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/chain b/src/fiat/chain deleted file mode 100755 index c55d30fbd..000000000 --- a/src/fiat/chain +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=CHAIN $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/coquicash b/src/fiat/coquicash deleted file mode 100755 index c882b2239..000000000 --- a/src/fiat/coquicash +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=COQUICASH $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/crypto b/src/fiat/crypto deleted file mode 100755 index 5a3d46188..000000000 --- a/src/fiat/crypto +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=CRYPTO $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/dex b/src/fiat/dex deleted file mode 100755 index 67331201a..000000000 --- a/src/fiat/dex +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=DEX $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/dion b/src/fiat/dion deleted file mode 100755 index 889f9e1ad..000000000 --- a/src/fiat/dion +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=DION $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/dsec b/src/fiat/dsec deleted file mode 100755 index a050ca94f..000000000 --- a/src/fiat/dsec +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=DSEC $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/eql b/src/fiat/eql deleted file mode 100755 index 99cfa9a09..000000000 --- a/src/fiat/eql +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=EQL $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/etomic b/src/fiat/etomic deleted file mode 100755 index 76eb0191c..000000000 --- a/src/fiat/etomic +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=ETOMIC $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/glxt b/src/fiat/glxt deleted file mode 100755 index 6cedfbf87..000000000 --- a/src/fiat/glxt +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=GLXT $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/hodl b/src/fiat/hodl deleted file mode 100755 index a5430db59..000000000 --- a/src/fiat/hodl +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=HODL $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/ilien b/src/fiat/ilien deleted file mode 100755 index 53e571661..000000000 --- a/src/fiat/ilien +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=ILN $1 $2 $3 $4 $5 $6 - diff --git a/src/fiat/iln b/src/fiat/iln deleted file mode 100755 index f453c338e..000000000 --- a/src/fiat/iln +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=ILN $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/jumblr b/src/fiat/jumblr deleted file mode 100755 index 2969c5009..000000000 --- a/src/fiat/jumblr +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=JUMBLR $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/k64 b/src/fiat/k64 deleted file mode 100755 index a3b3bc835..000000000 --- a/src/fiat/k64 +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=K64 $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/kmdice b/src/fiat/kmdice deleted file mode 100755 index ca91bf9a5..000000000 --- a/src/fiat/kmdice +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=KMDICE $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/koin b/src/fiat/koin deleted file mode 100755 index 7e76c6b54..000000000 --- a/src/fiat/koin +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=KOIN $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/ksb b/src/fiat/ksb deleted file mode 100755 index 450c3b3f6..000000000 --- a/src/fiat/ksb +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=KSB $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/kv b/src/fiat/kv deleted file mode 100755 index 997fccb33..000000000 --- a/src/fiat/kv +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=KV $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/mesh b/src/fiat/mesh deleted file mode 100755 index 19b359509..000000000 --- a/src/fiat/mesh +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=MESH $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/mgnx b/src/fiat/mgnx deleted file mode 100755 index 9bd85336e..000000000 --- a/src/fiat/mgnx +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=MGNX $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/mgw b/src/fiat/mgw deleted file mode 100755 index 9afa86b7a..000000000 --- a/src/fiat/mgw +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=MGW $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/mnz b/src/fiat/mnz deleted file mode 100755 index f4e1f3501..000000000 --- a/src/fiat/mnz +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=MNZ $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/morty b/src/fiat/morty deleted file mode 100755 index 4579324b7..000000000 --- a/src/fiat/morty +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=MORTY $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/mshark b/src/fiat/mshark deleted file mode 100755 index 1f0c950c6..000000000 --- a/src/fiat/mshark +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=MSHARK $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/ninja b/src/fiat/ninja deleted file mode 100755 index f7722abb0..000000000 --- a/src/fiat/ninja +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=NINJA $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/oot b/src/fiat/oot deleted file mode 100755 index 4c7c6b683..000000000 --- a/src/fiat/oot +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=OOT $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/our b/src/fiat/our deleted file mode 100755 index 66c774476..000000000 --- a/src/fiat/our +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=OUR $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/pangea b/src/fiat/pangea deleted file mode 100755 index 9920189ea..000000000 --- a/src/fiat/pangea +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=PANGEA $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/pgt b/src/fiat/pgt deleted file mode 100755 index 8e124bbd1..000000000 --- a/src/fiat/pgt +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=PGT $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/pirate b/src/fiat/pirate deleted file mode 100755 index 9314209da..000000000 --- a/src/fiat/pirate +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=PIRATE $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/pizza b/src/fiat/pizza deleted file mode 100755 index d8400d9d3..000000000 --- a/src/fiat/pizza +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=PIZZA $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/prlpay b/src/fiat/prlpay deleted file mode 100755 index 3d1063d13..000000000 --- a/src/fiat/prlpay +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=PRLPAY $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/revs b/src/fiat/revs deleted file mode 100755 index b898eb5dc..000000000 --- a/src/fiat/revs +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=REVS $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/rfox b/src/fiat/rfox deleted file mode 100755 index e082505d0..000000000 --- a/src/fiat/rfox +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=RFOX $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/rick b/src/fiat/rick deleted file mode 100755 index b68bd56ab..000000000 --- a/src/fiat/rick +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=RICK $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/sec b/src/fiat/sec deleted file mode 100755 index 185a76cf1..000000000 --- a/src/fiat/sec +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=SEC $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/supernet b/src/fiat/supernet deleted file mode 100755 index d841ffa0e..000000000 --- a/src/fiat/supernet +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=SUPERNET $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/thc b/src/fiat/thc deleted file mode 100755 index 84f9ea69c..000000000 --- a/src/fiat/thc +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=THC $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/wlc b/src/fiat/wlc deleted file mode 100755 index ef7c47b90..000000000 --- a/src/fiat/wlc +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=WLC $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/zexo b/src/fiat/zexo deleted file mode 100755 index b6fd508f2..000000000 --- a/src/fiat/zexo +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=ZEXO $1 $2 $3 $4 $5 $6 diff --git a/src/fiat/zilla b/src/fiat/zilla deleted file mode 100755 index d8c713369..000000000 --- a/src/fiat/zilla +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/bash -./komodo-cli -ac_name=ZILLA $1 $2 $3 $4 $5 $6 diff --git a/src/gui/komodoku/README.md b/src/gui/komodoku/README.md deleted file mode 100644 index 8a3778ea0..000000000 --- a/src/gui/komodoku/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/komodoku/Roboto-Light.ttf b/src/gui/komodoku/Roboto-Light.ttf deleted file mode 100755 index 664e1b2f9..000000000 Binary files a/src/gui/komodoku/Roboto-Light.ttf and /dev/null differ diff --git a/src/gui/komodoku/Sudoku.py b/src/gui/komodoku/Sudoku.py deleted file mode 100644 index 7b46d93fc..000000000 --- a/src/gui/komodoku/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/komodoku/background.png b/src/gui/komodoku/background.png deleted file mode 100644 index dc4844a0b..000000000 Binary files a/src/gui/komodoku/background.png and /dev/null differ diff --git a/src/gui/komodoku/board.png b/src/gui/komodoku/board.png deleted file mode 100644 index bd77ca419..000000000 Binary files a/src/gui/komodoku/board.png and /dev/null differ diff --git a/src/gui/komodoku/sudoku_kmdlib.py b/src/gui/komodoku/sudoku_kmdlib.py deleted file mode 100644 index a2b2aa239..000000000 --- a/src/gui/komodoku/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)))) - - diff --git a/src/komodo.h b/src/komodo.h index 1cfbd283b..01e81ed1c 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -56,7 +56,6 @@ bool check_pprevnotarizedht(); int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char *dest); #include "komodo_kv.h" -#include "komodo_jumblr.h" #include "komodo_gateway.h" #include "komodo_events.h" #include "komodo_ccdata.h" @@ -631,10 +630,10 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar 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); - len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&srchash); - len += iguana_rwnum(0,&scriptbuf[len],sizeof(*notarizedheightp),(uint8_t *)notarizedheightp); + len += dragon_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&srchash); + len += dragon_rwnum(0,&scriptbuf[len],sizeof(*notarizedheightp),(uint8_t *)notarizedheightp); if ( matched != 0 ) - len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&desttxid); + len += dragon_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&desttxid); if ( matched != 0 ) validated = komodo_validate_chain(srchash,*notarizedheightp); else validated = 1; @@ -655,13 +654,13 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar //printf("nameoffset.%d len.%d + 36 %d opoffset.%d vs opretlen.%d\n",nameoffset,len,len+36,opoffset,opretlen); if ( len+36-opoffset <= opretlen ) { - len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&MoM); - len += iguana_rwnum(0,&scriptbuf[len],sizeof(MoMdepth),(uint8_t *)&MoMdepth); + len += dragon_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&MoM); + len += dragon_rwnum(0,&scriptbuf[len],sizeof(MoMdepth),(uint8_t *)&MoMdepth); ccdata.MoMdata.MoM = MoM; ccdata.MoMdata.MoMdepth = MoMdepth & 0xffff; if ( len+sizeof(ccdata.CCid)-opoffset <= opretlen ) { - len += iguana_rwnum(0,&scriptbuf[len],sizeof(ccdata.CCid),(uint8_t *)&ccdata.CCid); + len += dragon_rwnum(0,&scriptbuf[len],sizeof(ccdata.CCid),(uint8_t *)&ccdata.CCid); //if ( ((MoMdepth>>16) & 0xffff) != (ccdata.CCid & 0xffff) ) // fprintf(stderr,"%s CCid mismatch %u != %u\n",ASSETCHAINS_SYMBOL,((MoMdepth>>16) & 0xffff),(ccdata.CCid & 0xffff)); ccdata.len = sizeof(ccdata.CCid); @@ -670,19 +669,19 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar // MoMoM, depth, numpairs, (notarization ht, MoMoM offset) if ( len+48-opoffset <= opretlen && strcmp(ccdata.symbol,ASSETCHAINS_SYMBOL) == 0 ) { - len += iguana_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.kmdstarti); - len += iguana_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.kmdendi); - len += iguana_rwbignum(0,&scriptbuf[len],sizeof(MoMoMdata.MoMoM),(uint8_t *)&MoMoMdata.MoMoM); - len += iguana_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.MoMoMdepth); - len += iguana_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.numpairs); + len += dragon_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.kmdstarti); + len += dragon_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.kmdendi); + len += dragon_rwbignum(0,&scriptbuf[len],sizeof(MoMoMdata.MoMoM),(uint8_t *)&MoMoMdata.MoMoM); + len += dragon_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.MoMoMdepth); + len += dragon_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.numpairs); MoMoMdata.len += sizeof(MoMoMdata.MoMoM) + sizeof(uint32_t)*4; if ( len+MoMoMdata.numpairs*8-opoffset == opretlen ) { MoMoMdata.pairs = (struct komodo_ccdatapair *)calloc(MoMoMdata.numpairs,sizeof(*MoMoMdata.pairs)); for (k=0; knumpairs > 0 ) { - len += iguana_rwnum(1,&hexdata[len],sizeof(CCid),(uint8_t *)&CCid); - len += iguana_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->kmdstarti); - len += iguana_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->kmdendi); - len += iguana_rwbignum(1,&hexdata[len],sizeof(mdata->MoMoM),(uint8_t *)&mdata->MoMoM); - len += iguana_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->MoMoMdepth); - len += iguana_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->numpairs); + len += dragon_rwnum(1,&hexdata[len],sizeof(CCid),(uint8_t *)&CCid); + len += dragon_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->kmdstarti); + len += dragon_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->kmdendi); + len += dragon_rwbignum(1,&hexdata[len],sizeof(mdata->MoMoM),(uint8_t *)&mdata->MoMoM); + len += dragon_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->MoMoMdepth); + len += dragon_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->numpairs); for (i=0; inumpairs; i++) { if ( len + sizeof(uint32_t)*2 > sizeof(hexdata) ) @@ -160,8 +160,8 @@ int32_t komodo_MoMoMdata(char *hexstr,int32_t hexsize,struct komodo_ccdataMoMoM fprintf(stderr,"%s %d %d i.%d of %d exceeds hexdata.%d\n",symbol,kmdheight,notarized_height,i,mdata->numpairs,(int32_t)sizeof(hexdata)); break; } - len += iguana_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->pairs[i].notarized_height); - len += iguana_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->pairs[i].MoMoMoffset); + len += dragon_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->pairs[i].notarized_height); + len += dragon_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->pairs[i].MoMoMoffset); } if ( i == mdata->numpairs && len*2+1 < hexsize ) { diff --git a/src/komodo_defs.h b/src/komodo_defs.h index e482390bb..c372ed3e4 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -265,7 +265,7 @@ static const char *notaries_elected[NUM_KMD_SEASONS][NUM_KMD_NOTARIES][2] = {"decker_AR", "03ffdf1a116300a78729608d9930742cd349f11a9d64fcc336b8f18592dd9c91bc" }, // 63 }, { - // Season 3.5 third party NN pubkeys from https://github.com/KomodoPlatform/dPoW/blob/master/iguana/3rd_party + // Season 3.5 third party NN pubkeys from https://github.com/KomodoPlatform/dPoW/blob/master/dragon/3rd_party {"madmax_NA", "02ef81a360411adf71184ff04d0c5793fc41fd1d7155a28dd909f21f35f4883ac1" }, {"alright_AR", "036a6bca1c2a8166f79fa8a979662892742346cc972b432f8e61950a358d705517" }, {"strob_NA", "02049202f3872877e81035549f6f3a0f868d0ad1c9b0e0d2b48b1f30324255d26d" }, @@ -332,7 +332,7 @@ static const char *notaries_elected[NUM_KMD_SEASONS][NUM_KMD_NOTARIES][2] = {"decker_AR", "02a85540db8d41c7e60bf0d33d1364b4151cad883dd032878ea4c037f67b769635" } }, { - // Season 4 https://github.com/KomodoPlatform/dPoW/blob/s4/iguana/3rd_party + // Season 4 https://github.com/KomodoPlatform/dPoW/blob/s4/dragon/3rd_party {"alien_AR", "024f20c096b085308e21893383f44b4faf1cdedea9ad53cc7d7e7fbfa0c30c1e71" }, {"alien_EU", "022b85908191788f409506ebcf96a892f3274f352864c3ed566c5a16de63953236" }, {"alien_NA", "022f62b56ddfd07c9860921c701285ac39bb3ac8f6f083d1b59c8f4943be3de162" }, diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index aba43e0aa..0d9616584 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -188,10 +188,10 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio pax->vout += ((uint32_t)opretbuf[len++] << 8); //printf(" txid v.%d\n",pax->vout); } - len += iguana_rwnum(rwflag,&opretbuf[len],sizeof(pax->komodoshis),&pax->komodoshis); - len += iguana_rwnum(rwflag,&opretbuf[len],sizeof(pax->fiatoshis),&pax->fiatoshis); - len += iguana_rwnum(rwflag,&opretbuf[len],sizeof(pax->height),&pax->height); - len += iguana_rwnum(rwflag,&opretbuf[len],sizeof(pax->otherheight),&pax->otherheight); + len += dragon_rwnum(rwflag,&opretbuf[len],sizeof(pax->komodoshis),&pax->komodoshis); + len += dragon_rwnum(rwflag,&opretbuf[len],sizeof(pax->fiatoshis),&pax->fiatoshis); + len += dragon_rwnum(rwflag,&opretbuf[len],sizeof(pax->height),&pax->height); + len += dragon_rwnum(rwflag,&opretbuf[len],sizeof(pax->otherheight),&pax->otherheight); if ( rwflag != 0 ) { memcpy(&opretbuf[len],pax->rmd160,20), len += 20; @@ -855,7 +855,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 tokomodo = 0; if ( opretlen == 38 ) // any KMD tx { - iguana_rwnum(0,&opretbuf[34],sizeof(kmdheight),&kmdheight); + dragon_rwnum(0,&opretbuf[34],sizeof(kmdheight),&kmdheight); memset(base,0,sizeof(base)); PAX_pubkey(0,&opretbuf[1],&addrtype,rmd160,base,&shortflag,&fiatoshis); bitcoin_address(coinaddr,addrtype,rmd160,20); @@ -998,7 +998,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 return(typestr); } tokomodo = 1; - iguana_rwnum(0,&opretbuf[34],sizeof(kmdheight),&kmdheight); + dragon_rwnum(0,&opretbuf[34],sizeof(kmdheight),&kmdheight); memset(base,0,sizeof(base)); PAX_pubkey(0,&opretbuf[1],&addrtype,rmd160,base,&shortflag,&komodoshis); bitcoin_address(coinaddr,addrtype,rmd160,20); @@ -1442,14 +1442,11 @@ void komodo_passport_iteration() lastinterest = komodo_chainactive_timestamp(); } refsp = komodo_stateptr(symbol,dest); - if ( ASSETCHAINS_SYMBOL[0] == 0 || strcmp(ASSETCHAINS_SYMBOL,"KMDCC") == 0 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 || strcmp(ASSETCHAINS_SYMBOL,"JUSTLIES") == 0 ) { refid = 33; limit = 10000000; - jumblr_iteration(); - } - else - { + } else { limit = 10000000; refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1; // illegal base -> baseid.-1 -> 0 if ( refid == 0 ) @@ -1458,11 +1455,6 @@ void komodo_passport_iteration() return; } } - /*if ( KOMODO_PAX == 0 ) - { - KOMODO_PASSPORT_INITDONE = 1; - return; - }*/ starttime = (uint32_t)time(NULL); if ( callcounter++ < 1 ) limit = 10000; diff --git a/src/komodo_jumblr.h b/src/komodo_jumblr.h deleted file mode 100644 index fca7395e5..000000000 --- a/src/komodo_jumblr.h +++ /dev/null @@ -1,795 +0,0 @@ -/****************************************************************************** - * 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. * - * * - ******************************************************************************/ - -/* - z_exportkey "zaddr" - z_exportwallet "filename" - z_getoperationstatus (["operationid", ... ]) - z_gettotalbalance ( minconf ) - z_importkey "zkey" ( rescan ) - z_importwallet "filename" - z_listaddresses - z_sendmany "fromaddress" [{"address":... ,"amount":..., "memo":""},...] ( minconf ) ( fee ) - */ - -#ifdef _WIN32 -#include -#endif -#include "komodo_defs.h" - -#define JUMBLR_ADDR "RGhxXpXSSBTBm9EvNsXnTQczthMCxHX91t" -#define JUMBLR_BTCADDR "18RmTJe9qMech8siuhYfMtHo8RtcN1obC6" -#define JUMBLR_MAXSECRETADDRS 777 -#define JUMBLR_SYNCHRONIZED_BLOCKS 10 -#define JUMBLR_INCR 9.965 -#define JUMBLR_FEE 0.001 -#define JUMBLR_TXFEE 0.01 -#define SMALLVAL 0.000000000000001 - -#define JUMBLR_ERROR_DUPLICATEDEPOSIT -1 -#define JUMBLR_ERROR_SECRETCANTBEDEPOSIT -2 -#define JUMBLR_ERROR_TOOMANYSECRETS -3 -#define JUMBLR_ERROR_NOTINWALLET -4 - -struct jumblr_item -{ - UT_hash_handle hh; - int64_t amount,fee,txfee; // fee and txfee not really used (yet) - uint32_t spent,pad; - char opid[66],src[128],dest[128],status; -} *Jumblrs; - -char Jumblr_secretaddrs[JUMBLR_MAXSECRETADDRS][64],Jumblr_deposit[64]; -int32_t Jumblr_numsecretaddrs; // if 0 -> run silent mode - -char *jumblr_issuemethod(char *userpass,char *method,char *params,uint16_t port) -{ - cJSON *retjson,*resjson = 0; char *retstr; - if ( (retstr= komodo_issuemethod(userpass,method,params,port)) != 0 ) - { - if ( (retjson= cJSON_Parse(retstr)) != 0 ) - { - if ( jobj(retjson,(char *)"result") != 0 ) - resjson = jduplicate(jobj(retjson,(char *)"result")); - else if ( jobj(retjson,(char *)"error") != 0 ) - resjson = jduplicate(jobj(retjson,(char *)"error")); - else - { - resjson = cJSON_CreateObject(); - jaddstr(resjson,(char *)"error",(char *)"cant parse return"); - } - free_json(retjson); - } - free(retstr); - } - if ( resjson != 0 ) - return(jprint(resjson,1)); - else return(clonestr((char *)"{\"error\":\"unknown error\"}")); -} - -char *jumblr_importaddress(char *address) -{ - char params[1024]; - sprintf(params,"[\"%s\", \"%s\", false]",address,address); - return(jumblr_issuemethod(KMDUSERPASS,(char *)"importaddress",params,BITCOIND_RPCPORT)); -} - -char *jumblr_validateaddress(char *addr) -{ - char params[1024]; - sprintf(params,"[\"%s\"]",addr); - printf("validateaddress.%s\n",params); - return(jumblr_issuemethod(KMDUSERPASS,(char *)"validateaddress",params,BITCOIND_RPCPORT)); -} - -int32_t Jumblr_secretaddrfind(char *searchaddr) -{ - int32_t i; - for (i=0; i 0 ) - { - OS_randombytes((uint8_t *)&r,sizeof(r)); - r %= Jumblr_numsecretaddrs; - safecopy(secretaddr,Jumblr_secretaddrs[r],64); - } - return(r); -} - -int32_t jumblr_addresstype(char *addr) -{ - if ( addr[0] == '"' && addr[strlen(addr)-1] == '"' ) - { - addr[strlen(addr)-1] = 0; - addr++; - } - if ( addr[0] == 'z' && addr[1] == 'c' && strlen(addr) >= 40 ) - return('z'); - else if ( strlen(addr) < 40 ) - return('t'); - printf("strange.(%s)\n",addr); - return(-1); -} - -struct jumblr_item *jumblr_opidfind(char *opid) -{ - struct jumblr_item *ptr; - HASH_FIND(hh,Jumblrs,opid,(int32_t)strlen(opid),ptr); - return(ptr); -} - -struct jumblr_item *jumblr_opidadd(char *opid) -{ - struct jumblr_item *ptr = 0; - if ( opid != 0 && (ptr= jumblr_opidfind(opid)) == 0 ) - { - ptr = (struct jumblr_item *)calloc(1,sizeof(*ptr)); - safecopy(ptr->opid,opid,sizeof(ptr->opid)); - HASH_ADD_KEYPTR(hh,Jumblrs,ptr->opid,(int32_t)strlen(ptr->opid),ptr); - if ( ptr != jumblr_opidfind(opid) ) - printf("jumblr_opidadd.(%s) ERROR, couldnt find after add\n",opid); - } - return(ptr); -} - -char *jumblr_zgetnewaddress() -{ - char params[1024]; - sprintf(params,"[]"); - return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_getnewaddress",params,BITCOIND_RPCPORT)); -} - -char *jumblr_zlistoperationids() -{ - char params[1024]; - sprintf(params,"[]"); - return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_listoperationids",params,BITCOIND_RPCPORT)); -} - -char *jumblr_zgetoperationresult(char *opid) -{ - char params[1024]; - sprintf(params,"[[\"%s\"]]",opid); - return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_getoperationresult",params,BITCOIND_RPCPORT)); -} - -char *jumblr_zgetoperationstatus(char *opid) -{ - char params[1024]; - sprintf(params,"[[\"%s\"]]",opid); - return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_getoperationstatus",params,BITCOIND_RPCPORT)); -} - -char *jumblr_sendt_to_z(char *taddr,char *zaddr,double amount) -{ - char params[1024]; double fee = ((amount-3*JUMBLR_TXFEE) * JUMBLR_FEE) * 1.5; - if ( jumblr_addresstype(zaddr) != 'z' || jumblr_addresstype(taddr) != 't' ) - return(clonestr((char *)"{\"error\":\"illegal address in t to z\"}")); - sprintf(params,"[\"%s\", [{\"address\":\"%s\",\"amount\":%.8f}, {\"address\":\"%s\",\"amount\":%.8f}], 1, %.8f]",taddr,zaddr,amount-fee-JUMBLR_TXFEE,JUMBLR_ADDR,fee,JUMBLR_TXFEE); - printf("t -> z: %s\n",params); - return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_sendmany",params,BITCOIND_RPCPORT)); -} - -char *jumblr_sendz_to_z(char *zaddrS,char *zaddrD,double amount) -{ - char params[1024]; double fee = (amount-2*JUMBLR_TXFEE) * JUMBLR_FEE; - if ( jumblr_addresstype(zaddrS) != 'z' || jumblr_addresstype(zaddrD) != 'z' ) - return(clonestr((char *)"{\"error\":\"illegal address in z to z\"}")); - //sprintf(params,"[\"%s\", [{\"address\":\"%s\",\"amount\":%.8f}, {\"address\":\"%s\",\"amount\":%.8f}], 1, %.8f]",zaddrS,zaddrD,amount-fee-JUMBLR_TXFEE,JUMBLR_ADDR,fee,JUMBLR_TXFEE); - sprintf(params,"[\"%s\", [{\"address\":\"%s\",\"amount\":%.8f}], 1, %.8f]",zaddrS,zaddrD,amount-fee-JUMBLR_TXFEE,JUMBLR_TXFEE); - printf("z -> z: %s\n",params); - return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_sendmany",params,BITCOIND_RPCPORT)); -} - -char *jumblr_sendz_to_t(char *zaddr,char *taddr,double amount) -{ - char params[1024]; double fee = ((amount-JUMBLR_TXFEE) * JUMBLR_FEE) * 1.5; - if ( jumblr_addresstype(zaddr) != 'z' || jumblr_addresstype(taddr) != 't' ) - return(clonestr((char *)"{\"error\":\"illegal address in z to t\"}")); - sprintf(params,"[\"%s\", [{\"address\":\"%s\",\"amount\":%.8f}, {\"address\":\"%s\",\"amount\":%.8f}], 1, %.8f]",zaddr,taddr,amount-fee-JUMBLR_TXFEE,JUMBLR_ADDR,fee,JUMBLR_TXFEE); - printf("z -> t: %s\n",params); - return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_sendmany",params,BITCOIND_RPCPORT)); -} - -char *jumblr_zlistaddresses() -{ - char params[1024]; - sprintf(params,"[]"); - return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_listaddresses",params,BITCOIND_RPCPORT)); -} - -char *jumblr_zlistreceivedbyaddress(char *addr) -{ - char params[1024]; - sprintf(params,"[\"%s\", 1]",addr); - return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_listreceivedbyaddress",params,BITCOIND_RPCPORT)); -} - -char *jumblr_getreceivedbyaddress(char *addr) -{ - char params[1024]; - sprintf(params,"[\"%s\", 1]",addr); - return(jumblr_issuemethod(KMDUSERPASS,(char *)"getreceivedbyaddress",params,BITCOIND_RPCPORT)); -} - -char *jumblr_importprivkey(char *wifstr) -{ - char params[1024]; - sprintf(params,"[\"%s\", \"\", false]",wifstr); - return(jumblr_issuemethod(KMDUSERPASS,(char *)"importprivkey",params,BITCOIND_RPCPORT)); -} - -char *jumblr_zgetbalance(char *addr) -{ - char params[1024]; - sprintf(params,"[\"%s\", 1]",addr); - return(jumblr_issuemethod(KMDUSERPASS,(char *)"z_getbalance",params,BITCOIND_RPCPORT)); -} - -char *jumblr_listunspent(char *coinaddr) -{ - char params[1024]; - sprintf(params,"[1, 99999999, [\"%s\"]]",coinaddr); - return(jumblr_issuemethod(KMDUSERPASS,(char *)"listunspent",params,BITCOIND_RPCPORT)); -} - -char *jumblr_gettransaction(char *txidstr) -{ - char params[1024]; - sprintf(params,"[\"%s\", 1]",txidstr); - return(jumblr_issuemethod(KMDUSERPASS,(char *)"getrawtransaction",params,BITCOIND_RPCPORT)); -} - -int32_t jumblr_numvins(bits256 txid) -{ - char txidstr[65],params[1024],*retstr; cJSON *retjson,*vins; int32_t n,numvins = -1; - bits256_str(txidstr,txid); - if ( (retstr= jumblr_gettransaction(txidstr)) != 0 ) - { - if ( (retjson= cJSON_Parse(retstr)) != 0 ) - { - if ( jobj(retjson,(char *)"vin") != 0 && ((vins= jarray(&n,retjson,(char *)"vin")) == 0 || n == 0) ) - { - numvins = n; - //printf("numvins.%d\n",n); - } //else printf("no vin.(%s)\n",retstr); - free_json(retjson); - } - free(retstr); - } - return(numvins); -} - -int64_t jumblr_receivedby(char *addr) -{ - char *retstr; int64_t total = 0; - if ( (retstr= jumblr_getreceivedbyaddress(addr)) != 0 ) - { - total = atof(retstr) * SATOSHIDEN; - free(retstr); - } - return(total); -} - -int64_t jumblr_balance(char *addr) -{ - char *retstr; double val; int64_t balance = 0; //cJSON *retjson; int32_t i,n; - /*if ( jumblr_addresstype(addr) == 't' ) - { - if ( (retstr= jumblr_listunspent(addr)) != 0 ) - { - //printf("jumblr.[%s].(%s)\n","KMD",retstr); - if ( (retjson= cJSON_Parse(retstr)) != 0 ) - { - if ( (n= cJSON_GetArraySize(retjson)) > 0 && cJSON_IsArray(retjson) != 0 ) - for (i=0; i SMALLVAL ) - balance = val * SATOSHIDEN; - free(retstr); - } - return(balance); -} - -int32_t jumblr_itemset(struct jumblr_item *ptr,cJSON *item,char *status) -{ - cJSON *params,*amounts,*dest; char *from,*addr; int32_t i,n; int64_t amount; - /*"params" : { - "fromaddress" : "RDhEGYScNQYetCyG75Kf8Fg61UWPdwc1C5", - "amounts" : [ - { - "address" : "zc9s3UdkDFTnnwHrMCr1vYy2WmkjhmTxXNiqC42s7BjeKBVUwk766TTSsrRPKfnX31Bbu8wbrTqnjDqskYGwx48FZMPHvft", - "amount" : 3.00000000 - } - ], - "minconf" : 1, - "fee" : 0.00010000 - }*/ - if ( (params= jobj(item,(char *)"params")) != 0 ) - { - //printf("params.(%s)\n",jprint(params,0)); - if ( (from= jstr(params,(char *)"fromaddress")) != 0 ) - { - safecopy(ptr->src,from,sizeof(ptr->src)); - } - if ( (amounts= jarray(&n,params,(char *)"amounts")) != 0 ) - { - for (i=0; i 0 ) - { - if ( strcmp(addr,JUMBLR_ADDR) == 0 ) - ptr->fee = amount; - else - { - ptr->amount = amount; - safecopy(ptr->dest,addr,sizeof(ptr->dest)); - } - } - } - } - ptr->txfee = jdouble(params,(char *)"fee") * SATOSHIDEN; - } - return(1); -} - -void jumblr_opidupdate(struct jumblr_item *ptr) -{ - char *retstr,*status; cJSON *retjson,*item; - if ( ptr->status == 0 ) - { - if ( (retstr= jumblr_zgetoperationstatus(ptr->opid)) != 0 ) - { - if ( (retjson= cJSON_Parse(retstr)) != 0 ) - { - if ( cJSON_GetArraySize(retjson) == 1 && cJSON_IsArray(retjson) != 0 ) - { - item = jitem(retjson,0); - //printf("%s\n",jprint(item,0)); - if ( (status= jstr(item,(char *)"status")) != 0 ) - { - if ( strcmp(status,(char *)"success") == 0 ) - { - ptr->status = jumblr_itemset(ptr,item,status); - if ( (jumblr_addresstype(ptr->src) == 't' && jumblr_addresstype(ptr->src) == 'z' && strcmp(ptr->src,Jumblr_deposit) != 0) || (jumblr_addresstype(ptr->src) == 'z' && jumblr_addresstype(ptr->src) == 't' && Jumblr_secretaddrfind(ptr->dest) < 0) ) - { - printf("a non-jumblr t->z pruned\n"); - free(jumblr_zgetoperationresult(ptr->opid)); - ptr->status = -1; - } - - } - else if ( strcmp(status,(char *)"failed") == 0 ) - { - printf("jumblr_opidupdate %s failed\n",ptr->opid); - free(jumblr_zgetoperationresult(ptr->opid)); - ptr->status = -1; - } - } - } - free_json(retjson); - } - free(retstr); - } - } -} - -void jumblr_prune(struct jumblr_item *ptr) -{ - struct jumblr_item *tmp; char oldsrc[128]; int32_t flag = 1; - if ( is_hexstr(ptr->opid,0) == 64 ) - return; - printf("jumblr_prune %s\n",ptr->opid); - strcpy(oldsrc,ptr->src); - free(jumblr_zgetoperationresult(ptr->opid)); - while ( flag != 0 ) - { - flag = 0; - HASH_ITER(hh,Jumblrs,ptr,tmp) - { - if ( strcmp(oldsrc,ptr->dest) == 0 ) - { - if ( is_hexstr(ptr->opid,0) != 64 ) - { - printf("jumblr_prune %s (%s -> %s) matched oldsrc\n",ptr->opid,ptr->src,ptr->dest); - free(jumblr_zgetoperationresult(ptr->opid)); - strcpy(oldsrc,ptr->src); - flag = 1; - break; - } - } - } - } -} - - -bits256 jbits256(cJSON *json,char *field); - - -void jumblr_zaddrinit(char *zaddr) -{ - struct jumblr_item *ptr; char *retstr,*totalstr; cJSON *item,*array; double total; bits256 txid; char txidstr[65],t_z,z_z; - if ( (totalstr= jumblr_zgetbalance(zaddr)) != 0 ) - { - if ( (total= atof(totalstr)) > SMALLVAL ) - { - if ( (retstr= jumblr_zlistreceivedbyaddress(zaddr)) != 0 ) - { - if ( (array= cJSON_Parse(retstr)) != 0 ) - { - t_z = z_z = 0; - if ( cJSON_GetArraySize(array) == 1 && cJSON_IsArray(array) != 0 ) - { - item = jitem(array,0); - if ( (uint64_t)((total+0.0000000049) * SATOSHIDEN) == (uint64_t)((jdouble(item,(char *)"amount")+0.0000000049) * SATOSHIDEN) ) - { - txid = jbits256(item,(char *)"txid"); - bits256_str(txidstr,txid); - if ( (ptr= jumblr_opidadd(txidstr)) != 0 ) - { - ptr->amount = (total * SATOSHIDEN); - ptr->status = 1; - strcpy(ptr->dest,zaddr); - if ( jumblr_addresstype(ptr->dest) != 'z' ) - printf("error setting dest type to Z: %s\n",jprint(item,0)); - if ( jumblr_numvins(txid) == 0 ) - { - z_z = 1; - strcpy(ptr->src,zaddr); - ptr->src[3] = '0'; - ptr->src[4] = '0'; - ptr->src[5] = '0'; - if ( jumblr_addresstype(ptr->src) != 'z' ) - printf("error setting address type to Z: %s\n",jprint(item,0)); - } - else - { - t_z = 1; - strcpy(ptr->src,"taddr"); - if ( jumblr_addresstype(ptr->src) != 't' ) - printf("error setting address type to T: %s\n",jprint(item,0)); - } - printf("%s %s %.8f t_z.%d z_z.%d\n",zaddr,txidstr,total,t_z,z_z); // cant be z->t from spend - } - } else printf("mismatched %s %s total %.8f vs %.8f -> %lld\n",zaddr,totalstr,dstr(SATOSHIDEN * total),dstr(SATOSHIDEN * jdouble(item,(char *)"amount")),(long long)((uint64_t)(total * SATOSHIDEN) - (uint64_t)(jdouble(item,(char *)"amount") * SATOSHIDEN))); - } - free_json(array); - } - free(retstr); - } - } - free(totalstr); - } -} - -void jumblr_opidsupdate() -{ - char *retstr; cJSON *array; int32_t i,n; struct jumblr_item *ptr; - if ( (retstr= jumblr_zlistoperationids()) != 0 ) - { - if ( (array= cJSON_Parse(retstr)) != 0 ) - { - if ( (n= cJSON_GetArraySize(array)) > 0 && cJSON_IsArray(array) != 0 ) - { - //printf("%s -> n%d\n",retstr,n); - for (i=0; istatus == 0 ) - jumblr_opidupdate(ptr); - //printf("%d: %s -> %s %.8f\n",ptr->status,ptr->src,ptr->dest,dstr(ptr->amount)); - if ( jumblr_addresstype(ptr->src) == 'z' && jumblr_addresstype(ptr->dest) == 't' ) - jumblr_prune(ptr); - } - } - } - free_json(array); - } - free(retstr); - } -} - -uint64_t jumblr_increment(uint8_t r,int32_t height,uint64_t total,uint64_t biggest,uint64_t medium, uint64_t smallest) -{ - int32_t i,n; uint64_t incrs[1000],remains = total; - height /= JUMBLR_SYNCHRONIZED_BLOCKS; - if ( (height % JUMBLR_SYNCHRONIZED_BLOCKS) == 0 || total >= 100*biggest ) - { - if ( total >= biggest ) - return(biggest); - else if ( total >= medium ) - return(medium); - else if ( total >= smallest ) - return(smallest); - else return(0); - } - else - { - n = 0; - while ( remains > smallest && n < sizeof(incrs)/sizeof(*incrs) ) - { - if ( remains >= biggest ) - incrs[n] = biggest; - else if ( remains >= medium ) - incrs[n] = medium; - else if ( remains >= smallest ) - incrs[n] = smallest; - else break; - remains -= incrs[n]; - n++; - } - if ( n > 0 ) - { - r %= n; - for (i=0; i %.8f\n",n,r,dstr(incrs[r])); - return(incrs[r]); - } - } - return(0); -} - -void jumblr_iteration() -{ - static int32_t lastheight; static uint32_t lasttime; - 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; - if ( JUMBLR_PAUSE != 0 || acpublic != 0 ) - return; - if ( lasttime == 0 ) - { - if ( (retstr= jumblr_zlistaddresses()) != 0 ) - { - if ( (array= cJSON_Parse(retstr)) != 0 ) - { - if ( (n= cJSON_GetArraySize(array)) > 0 && cJSON_IsArray(array) != 0 ) - { - for (i=0; iGetHeight(); - if ( time(NULL) < lasttime+40 ) - return; - lasttime = (uint32_t)time(NULL); - if ( lastheight == height ) - return; - lastheight = height; - if ( (height % JUMBLR_SYNCHRONIZED_BLOCKS) != JUMBLR_SYNCHRONIZED_BLOCKS-3 ) - return; - fee = JUMBLR_INCR * JUMBLR_FEE; - smallest = SATOSHIDEN * ((JUMBLR_INCR + 3*fee) + 3*JUMBLR_TXFEE); - medium = SATOSHIDEN * ((JUMBLR_INCR + 3*fee)*10 + 3*JUMBLR_TXFEE); - biggest = SATOSHIDEN * ((JUMBLR_INCR + 3*fee)*777 + 3*JUMBLR_TXFEE); - OS_randombytes((uint8_t *)&r,sizeof(r)); - s = (r % 3); - //printf("jumblr_iteration r.%u s.%u\n",r,s); - switch ( s ) - { - case 0: // t -> z - default: - if ( Jumblr_deposit[0] != 0 && (total= jumblr_balance(Jumblr_deposit)) >= smallest ) - { - if ( (zaddr= jumblr_zgetnewaddress()) != 0 ) - { - if ( zaddr[0] == '"' && zaddr[strlen(zaddr)-1] == '"' ) - { - zaddr[strlen(zaddr)-1] = 0; - addr = zaddr+1; - } else addr = zaddr; - amount = jumblr_increment(r/3,height,total,biggest,medium,smallest); - /* - amount = 0; - if ( (height % (JUMBLR_SYNCHRONIZED_BLOCKS*JUMBLR_SYNCHRONIZED_BLOCKS)) == 0 && total >= SATOSHIDEN * ((JUMBLR_INCR + 3*fee)*100 + 3*JUMBLR_TXFEE) ) - amount = SATOSHIDEN * ((JUMBLR_INCR + 3*fee)*100 + 3*JUMBLR_TXFEE); - else if ( (r & 3) == 0 && total >= SATOSHIDEN * ((JUMBLR_INCR + 3*fee)*10 + 3*JUMBLR_TXFEE) ) - amount = SATOSHIDEN * ((JUMBLR_INCR + 3*fee)*10 + 3*JUMBLR_TXFEE); - else amount = SATOSHIDEN * ((JUMBLR_INCR + 3*fee) + 3*JUMBLR_TXFEE);*/ - if ( amount > 0 && (retstr= jumblr_sendt_to_z(Jumblr_deposit,addr,dstr(amount))) != 0 ) - { - printf("sendt_to_z.(%s)\n",retstr); - free(retstr), retstr = 0; - } - free(zaddr); - } else printf("no zaddr from jumblr_zgetnewaddress\n"); - } - else if ( Jumblr_deposit[0] != 0 ) - printf("%s total %.8f vs %.8f\n",Jumblr_deposit,dstr(total),(JUMBLR_INCR + 3*(fee+JUMBLR_TXFEE))); - break; - case 1: // z -> z - jumblr_opidsupdate(); - chosen_one = -1; - for (iter=counter=0; iter<2; iter++) - { - counter = n = 0; - HASH_ITER(hh,Jumblrs,ptr,tmp) - { - if ( ptr->spent == 0 && ptr->status > 0 && jumblr_addresstype(ptr->src) == 't' && jumblr_addresstype(ptr->dest) == 'z' ) - { - if ( (total= jumblr_balance(ptr->dest)) >= (fee + JUMBLR_FEE)*SATOSHIDEN ) - { - if ( iter == 1 && counter == chosen_one ) - { - if ( (zaddr= jumblr_zgetnewaddress()) != 0 ) - { - if ( zaddr[0] == '"' && zaddr[strlen(zaddr)-1] == '"' ) - { - zaddr[strlen(zaddr)-1] = 0; - addr = zaddr+1; - } else addr = zaddr; - 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), retstr = 0; - } - ptr->spent = (uint32_t)time(NULL); - free(zaddr); - break; - } - } - counter++; - } - } - n++; - } - if ( counter == 0 ) - break; - if ( iter == 0 ) - { - OS_randombytes((uint8_t *)&chosen_one,sizeof(chosen_one)); - if ( chosen_one < 0 ) - chosen_one = -chosen_one; - chosen_one %= counter; - printf("jumblr z->z chosen_one.%d of %d, from %d\n",chosen_one,counter,n); - } - } - break; - case 2: // z -> t - if ( Jumblr_numsecretaddrs > 0 ) - { - jumblr_opidsupdate(); - chosen_one = -1; - for (iter=0; iter<2; iter++) - { - counter = n = 0; - HASH_ITER(hh,Jumblrs,ptr,tmp) - { - //printf("status.%d %c %c %.8f\n",ptr->status,jumblr_addresstype(ptr->src),jumblr_addresstype(ptr->dest),dstr(ptr->amount)); - if ( ptr->spent == 0 && ptr->status > 0 && jumblr_addresstype(ptr->src) == 'z' && jumblr_addresstype(ptr->dest) == 'z' ) - { - if ( (total= jumblr_balance(ptr->dest)) >= (fee + JUMBLR_FEE)*SATOSHIDEN ) - { - if ( iter == 1 && counter == chosen_one ) - { - Jumblr_secretaddr(secretaddr); - if ( (retstr= jumblr_sendz_to_t(ptr->dest,secretaddr,dstr(total))) != 0 ) - { - printf("%s send z_to_t.(%s)\n",secretaddr,retstr); - free(retstr), retstr = 0; - } else printf("null return from jumblr_sendz_to_t\n"); - ptr->spent = (uint32_t)time(NULL); - break; - } - counter++; - } //else printf("z->t spent.%u total %.8f error\n",ptr->spent,dstr(total)); - } - n++; - } - if ( counter == 0 ) - break; - if ( iter == 0 ) - { - OS_randombytes((uint8_t *)&chosen_one,sizeof(chosen_one)); - if ( chosen_one < 0 ) - chosen_one = -chosen_one; - chosen_one %= counter; - printf("jumblr z->t chosen_one.%d of %d, from %d\n",chosen_one,counter,n); - } //else printf("n.%d counter.%d chosen.%d\n",n,counter,chosen_one); - } - } - break; - } -} diff --git a/src/komodo_kv.h b/src/komodo_kv.h index a879340ff..be7eb8515 100644 --- a/src/komodo_kv.h +++ b/src/komodo_kv.h @@ -103,10 +103,10 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value) uint32_t flags; uint256 pubkey,refpubkey,sig; int32_t i,refvaluesize,hassig,coresize,haspubkey,height,kvheight; uint16_t keylen,valuesize,newflag = 0; uint8_t *key,*valueptr,keyvalue[IGUANA_MAXSCRIPTSIZE*8]; struct komodo_kv *ptr; char *transferpubstr,*tstr; uint64_t fee; if ( ASSETCHAINS_SYMBOL[0] == 0 ) // disable KV for KMD return; - iguana_rwnum(0,&opretbuf[1],sizeof(keylen),&keylen); - iguana_rwnum(0,&opretbuf[3],sizeof(valuesize),&valuesize); - iguana_rwnum(0,&opretbuf[5],sizeof(height),&height); - iguana_rwnum(0,&opretbuf[9],sizeof(flags),&flags); + dragon_rwnum(0,&opretbuf[1],sizeof(keylen),&keylen); + dragon_rwnum(0,&opretbuf[3],sizeof(valuesize),&valuesize); + dragon_rwnum(0,&opretbuf[5],sizeof(height),&height); + dragon_rwnum(0,&opretbuf[9],sizeof(flags),&flags); key = &opretbuf[13]; if ( keylen+13 > opretlen ) { diff --git a/src/komodo_nSPV.h b/src/komodo_nSPV.h index fe4d784cb..ac6168c35 100644 --- a/src/komodo_nSPV.h +++ b/src/komodo_nSPV.h @@ -26,7 +26,7 @@ #ifndef KOMODO_NSPV_H #define KOMODO_NSPV_H -int32_t iguana_rwbuf(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *buf) +int32_t dragon_rwbuf(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *buf) { if ( rwflag != 0 ) memcpy(serialized,buf,len); @@ -37,21 +37,21 @@ int32_t iguana_rwbuf(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *buf int32_t NSPV_rwequihdr(int32_t rwflag,uint8_t *serialized,struct NSPV_equihdr *ptr) { int32_t len = 0; - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nVersion),&ptr->nVersion); - len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->hashPrevBlock),(uint8_t *)&ptr->hashPrevBlock); - len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->hashMerkleRoot),(uint8_t *)&ptr->hashMerkleRoot); - len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->hashFinalSaplingRoot),(uint8_t *)&ptr->hashFinalSaplingRoot); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nTime),&ptr->nTime); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nBits),&ptr->nBits); - len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->nNonce),(uint8_t *)&ptr->nNonce); - len += iguana_rwbuf(rwflag,&serialized[len],sizeof(ptr->nSolution),ptr->nSolution); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->nVersion),&ptr->nVersion); + len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->hashPrevBlock),(uint8_t *)&ptr->hashPrevBlock); + len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->hashMerkleRoot),(uint8_t *)&ptr->hashMerkleRoot); + len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->hashFinalSaplingRoot),(uint8_t *)&ptr->hashFinalSaplingRoot); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->nTime),&ptr->nTime); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->nBits),&ptr->nBits); + len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->nNonce),(uint8_t *)&ptr->nNonce); + len += dragon_rwbuf(rwflag,&serialized[len],sizeof(ptr->nSolution),ptr->nSolution); return(len); } -int32_t iguana_rwequihdrvec(int32_t rwflag,uint8_t *serialized,uint16_t *vecsizep,struct NSPV_equihdr **ptrp) +int32_t dragon_rwequihdrvec(int32_t rwflag,uint8_t *serialized,uint16_t *vecsizep,struct NSPV_equihdr **ptrp) { int32_t i,vsize,len = 0; - len += iguana_rwnum(rwflag,&serialized[len],sizeof(*vecsizep),vecsizep); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(*vecsizep),vecsizep); if ( (vsize= *vecsizep) != 0 ) { //fprintf(stderr,"vsize.%d ptrp.%p alloc %ld\n",vsize,*ptrp,sizeof(struct NSPV_equihdr)*vsize); @@ -63,15 +63,15 @@ int32_t iguana_rwequihdrvec(int32_t rwflag,uint8_t *serialized,uint16_t *vecsize return(len); } -int32_t iguana_rwuint8vec(int32_t rwflag,uint8_t *serialized,int32_t *biglenp,uint8_t **ptrp) +int32_t dragon_rwuint8vec(int32_t rwflag,uint8_t *serialized,int32_t *biglenp,uint8_t **ptrp) { int32_t vsize,len = 0; - len += iguana_rwnum(rwflag,&serialized[len],sizeof(*biglenp),biglenp); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(*biglenp),biglenp); if ( (vsize= *biglenp) > 0 && vsize < MAX_TX_SIZE_AFTER_SAPLING ) { if ( *ptrp == 0 ) *ptrp = (uint8_t *)calloc(1,vsize); - len += iguana_rwbuf(rwflag,&serialized[len],vsize,*ptrp); + len += dragon_rwbuf(rwflag,&serialized[len],vsize,*ptrp); } return(len); } @@ -79,18 +79,18 @@ int32_t iguana_rwuint8vec(int32_t rwflag,uint8_t *serialized,int32_t *biglenp,ui int32_t NSPV_rwutxoresp(int32_t rwflag,uint8_t *serialized,struct NSPV_utxoresp *ptr) { int32_t len = 0; - len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->satoshis),&ptr->satoshis); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->extradata),&ptr->extradata); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->height),&ptr->height); + len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->satoshis),&ptr->satoshis); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->extradata),&ptr->extradata); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->height),&ptr->height); return(len); } int32_t NSPV_rwutxosresp(int32_t rwflag,uint8_t *serialized,struct NSPV_utxosresp *ptr) // check mempool { int32_t i,len = 0; - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->numutxos),&ptr->numutxos); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->numutxos),&ptr->numutxos); if ( ptr->numutxos != 0 ) { if ( ptr->utxos == 0 ) @@ -98,12 +98,12 @@ int32_t NSPV_rwutxosresp(int32_t rwflag,uint8_t *serialized,struct NSPV_utxosres for (i=0; inumutxos; i++) len += NSPV_rwutxoresp(rwflag,&serialized[len],&ptr->utxos[i]); } - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->total),&ptr->total); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->interest),&ptr->interest); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nodeheight),&ptr->nodeheight); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->filter),&ptr->filter); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->CCflag),&ptr->CCflag); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->skipcount),&ptr->skipcount); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->total),&ptr->total); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->interest),&ptr->interest); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->nodeheight),&ptr->nodeheight); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->filter),&ptr->filter); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->CCflag),&ptr->CCflag); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->skipcount),&ptr->skipcount); if ( rwflag != 0 ) { memcpy(&serialized[len],ptr->coinaddr,sizeof(ptr->coinaddr)); @@ -140,17 +140,17 @@ void NSPV_utxosresp_copy(struct NSPV_utxosresp *dest,struct NSPV_utxosresp *ptr) int32_t NSPV_rwtxidresp(int32_t rwflag,uint8_t *serialized,struct NSPV_txidresp *ptr) { int32_t len = 0; - len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->satoshis),&ptr->satoshis); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->height),&ptr->height); + len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->satoshis),&ptr->satoshis); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->height),&ptr->height); return(len); } int32_t NSPV_rwtxidsresp(int32_t rwflag,uint8_t *serialized,struct NSPV_txidsresp *ptr) { int32_t i,len = 0; - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->numtxids),&ptr->numtxids); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->numtxids),&ptr->numtxids); if ( ptr->numtxids != 0 ) { if ( ptr->txids == 0 ) @@ -158,10 +158,10 @@ int32_t NSPV_rwtxidsresp(int32_t rwflag,uint8_t *serialized,struct NSPV_txidsres for (i=0; inumtxids; i++) len += NSPV_rwtxidresp(rwflag,&serialized[len],&ptr->txids[i]); } - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nodeheight),&ptr->nodeheight); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->filter),&ptr->filter); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->CCflag),&ptr->CCflag); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->skipcount),&ptr->skipcount); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->nodeheight),&ptr->nodeheight); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->filter),&ptr->filter); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->CCflag),&ptr->CCflag); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->skipcount),&ptr->skipcount); if ( rwflag != 0 ) { memcpy(&serialized[len],ptr->coinaddr,sizeof(ptr->coinaddr)); @@ -199,20 +199,20 @@ void NSPV_txidsresp_copy(struct NSPV_txidsresp *dest,struct NSPV_txidsresp *ptr) int32_t NSPV_rwmempoolresp(int32_t rwflag,uint8_t *serialized,struct NSPV_mempoolresp *ptr) { int32_t i,len = 0; - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->numtxids),&ptr->numtxids); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->numtxids),&ptr->numtxids); if ( ptr->numtxids != 0 ) { if ( ptr->txids == 0 ) ptr->txids = (uint256 *)calloc(sizeof(*ptr->txids),ptr->numtxids); for (i=0; inumtxids; i++) - len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->txids[i]),(uint8_t *)&ptr->txids[i]); + len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->txids[i]),(uint8_t *)&ptr->txids[i]); } - len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nodeheight),&ptr->nodeheight); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->vindex),&ptr->vindex); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->CCflag),&ptr->CCflag); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->funcid),&ptr->funcid); + len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->nodeheight),&ptr->nodeheight); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->vindex),&ptr->vindex); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->CCflag),&ptr->CCflag); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->funcid),&ptr->funcid); if ( rwflag != 0 ) { memcpy(&serialized[len],ptr->coinaddr,sizeof(ptr->coinaddr)); @@ -250,12 +250,12 @@ void NSPV_mempoolresp_copy(struct NSPV_mempoolresp *dest,struct NSPV_mempoolresp int32_t NSPV_rwntz(int32_t rwflag,uint8_t *serialized,struct NSPV_ntz *ptr) { int32_t len = 0; - len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->blockhash),(uint8_t *)&ptr->blockhash); - len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid); - len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->othertxid),(uint8_t *)&ptr->othertxid); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->height),&ptr->height); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->txidheight),&ptr->txidheight); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->timestamp),&ptr->timestamp); + len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->blockhash),(uint8_t *)&ptr->blockhash); + len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid); + len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->othertxid),(uint8_t *)&ptr->othertxid); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->height),&ptr->height); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->txidheight),&ptr->txidheight); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->timestamp),&ptr->timestamp); return(len); } @@ -264,7 +264,7 @@ int32_t NSPV_rwntzsresp(int32_t rwflag,uint8_t *serialized,struct NSPV_ntzsresp int32_t len = 0; len += NSPV_rwntz(rwflag,&serialized[len],&ptr->prevntz); len += NSPV_rwntz(rwflag,&serialized[len],&ptr->nextntz); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->reqheight),&ptr->reqheight); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->reqheight),&ptr->reqheight); return(len); } @@ -283,11 +283,11 @@ int32_t NSPV_rwinforesp(int32_t rwflag,uint8_t *serialized,struct NSPV_inforesp { int32_t len = 0; len += NSPV_rwntz(rwflag,&serialized[len],&ptr->notarization); - len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->blockhash),(uint8_t *)&ptr->blockhash); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->height),&ptr->height); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->hdrheight),&ptr->hdrheight); + len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->blockhash),(uint8_t *)&ptr->blockhash); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->height),&ptr->height); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->hdrheight),&ptr->hdrheight); len += NSPV_rwequihdr(rwflag,&serialized[len],&ptr->H); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->version),&ptr->version); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->version),&ptr->version); //fprintf(stderr,"getinfo rwlen.%d\n",len); return(len); } @@ -301,13 +301,13 @@ void NSPV_inforesp_purge(struct NSPV_inforesp *ptr) int32_t NSPV_rwtxproof(int32_t rwflag,uint8_t *serialized,struct NSPV_txproof *ptr) { int32_t len = 0; - len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->unspentvalue),&ptr->unspentvalue); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->height),&ptr->height); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout); - len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->txlen,&ptr->tx); - len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->txprooflen,&ptr->txproof); - len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->hashblock),(uint8_t *)&ptr->hashblock); + len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->unspentvalue),&ptr->unspentvalue); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->height),&ptr->height); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout); + len += dragon_rwuint8vec(rwflag,&serialized[len],&ptr->txlen,&ptr->tx); + len += dragon_rwuint8vec(rwflag,&serialized[len],&ptr->txprooflen,&ptr->txproof); + len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->hashblock),(uint8_t *)&ptr->hashblock); return(len); } @@ -341,11 +341,11 @@ void NSPV_txproof_purge(struct NSPV_txproof *ptr) int32_t NSPV_rwntzproofshared(int32_t rwflag,uint8_t *serialized,struct NSPV_ntzproofshared *ptr) { int32_t len = 0; - len += iguana_rwequihdrvec(rwflag,&serialized[len],&ptr->numhdrs,&ptr->hdrs); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->prevht),&ptr->prevht); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nextht),&ptr->nextht); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->pad32),&ptr->pad32); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->pad16),&ptr->pad16); + len += dragon_rwequihdrvec(rwflag,&serialized[len],&ptr->numhdrs,&ptr->hdrs); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->prevht),&ptr->prevht); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->nextht),&ptr->nextht); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->pad32),&ptr->pad32); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->pad16),&ptr->pad16); //fprintf(stderr,"rwcommon prev.%d next.%d\n",ptr->prevht,ptr->nextht); return(len); } @@ -354,12 +354,12 @@ int32_t NSPV_rwntzsproofresp(int32_t rwflag,uint8_t *serialized,struct NSPV_ntzs { int32_t len = 0; len += NSPV_rwntzproofshared(rwflag,&serialized[len],&ptr->common); - len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->prevtxid),(uint8_t *)&ptr->prevtxid); - len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->nexttxid),(uint8_t *)&ptr->nexttxid); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->prevtxidht),&ptr->prevtxidht); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nexttxidht),&ptr->nexttxidht); - len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->prevtxlen,&ptr->prevntz); - len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->nexttxlen,&ptr->nextntz); + len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->prevtxid),(uint8_t *)&ptr->prevtxid); + len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->nexttxid),(uint8_t *)&ptr->nexttxid); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->prevtxidht),&ptr->prevtxidht); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->nexttxidht),&ptr->nexttxidht); + len += dragon_rwuint8vec(rwflag,&serialized[len],&ptr->prevtxlen,&ptr->prevntz); + len += dragon_rwuint8vec(rwflag,&serialized[len],&ptr->nexttxlen,&ptr->nextntz); //fprintf(stderr,"retlen.%d\n",len); return(len); } @@ -402,9 +402,9 @@ int32_t NSPV_rwspentinfo(int32_t rwflag,uint8_t *serialized,struct NSPV_spentinf { int32_t len = 0; len += NSPV_rwtxproof(rwflag,&serialized[len],&ptr->spent); - len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->spentvini),&ptr->spentvini); + len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->spentvini),&ptr->spentvini); return(len); } @@ -420,8 +420,8 @@ void NSPV_spentinfo_purge(struct NSPV_spentinfo *ptr) int32_t NSPV_rwbroadcastresp(int32_t rwflag,uint8_t *serialized,struct NSPV_broadcastresp *ptr) { int32_t len = 0; - len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid); - len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->retcode),&ptr->retcode); + len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid); + len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->retcode),&ptr->retcode); return(len); } @@ -434,8 +434,8 @@ void NSPV_broadcast_purge(struct NSPV_broadcastresp *ptr) int32_t NSPV_rwremoterpcresp(int32_t rwflag,uint8_t *serialized,struct NSPV_remoterpcresp *ptr, int32_t slen) { int32_t len = 0; - len+=iguana_rwbuf(rwflag,&serialized[len],sizeof(ptr->method),(uint8_t*)ptr->method); - len+=iguana_rwbuf(rwflag,&serialized[len],slen-len,(uint8_t*)ptr->json); + len+=dragon_rwbuf(rwflag,&serialized[len],sizeof(ptr->method),(uint8_t*)ptr->method); + len+=dragon_rwbuf(rwflag,&serialized[len],slen-len,(uint8_t*)ptr->json); return(len); } @@ -562,7 +562,7 @@ int32_t NSPV_notariescount(CTransaction tx,uint8_t elected[64][33]) uint256 NSPV_opretextract(int32_t *heightp,uint256 *blockhashp,char *symbol,std::vector opret,uint256 txid) { uint256 desttxid; int32_t i; - iguana_rwnum(0,&opret[32],sizeof(*heightp),heightp); + dragon_rwnum(0,&opret[32],sizeof(*heightp),heightp); for (i=0; i<32; i++) ((uint8_t *)blockhashp)[i] = opret[i]; for (i=0; i<32; i++) diff --git a/src/komodo_nSPV_fullnode.h b/src/komodo_nSPV_fullnode.h index 90ec9027c..468e14b04 100644 --- a/src/komodo_nSPV_fullnode.h +++ b/src/komodo_nSPV_fullnode.h @@ -637,13 +637,13 @@ int32_t NSPV_mempooltxids(struct NSPV_mempoolresp *ptr,char *coinaddr,uint8_t is for (i=0; inumtxids; i++) { tmp = txids[i]; - iguana_rwbignum(0,(uint8_t *)&tmp,sizeof(*ptr->txids),(uint8_t *)&ptr->txids[i]); + dragon_rwbignum(0,(uint8_t *)&tmp,sizeof(*ptr->txids),(uint8_t *)&ptr->txids[i]); } } if ( funcid == NSPV_MEMPOOL_ADDRESS ) { memcpy(&tmp,&satoshis,sizeof(tmp)); - iguana_rwbignum(0,(uint8_t *)&tmp,sizeof(ptr->txid),(uint8_t *)&ptr->txid); + dragon_rwbignum(0,(uint8_t *)&tmp,sizeof(ptr->txid),(uint8_t *)&ptr->txid); } len = (int32_t)(sizeof(*ptr) + sizeof(*ptr->txids)*ptr->numtxids - sizeof(ptr->txids)); return(len); @@ -883,7 +883,7 @@ void komodo_nSPVreq(CNode *pfrom,std::vector request) // received a req { struct NSPV_inforesp I; if ( len == 1+sizeof(reqheight) ) - iguana_rwnum(0,&request[1],sizeof(reqheight),&reqheight); + dragon_rwnum(0,&request[1],sizeof(reqheight),&reqheight); else reqheight = 0; //fprintf(stderr,"request height.%d\n",reqheight); memset(&I,0,sizeof(I)); @@ -918,13 +918,13 @@ void komodo_nSPVreq(CNode *pfrom,std::vector request) // received a req else if ( request[1] == len-7 ) { isCC = (request[len-5] != 0); - iguana_rwnum(0,&request[len-4],sizeof(skipcount),&skipcount); + dragon_rwnum(0,&request[len-4],sizeof(skipcount),&skipcount); } else { isCC = (request[len-9] != 0); - iguana_rwnum(0,&request[len-8],sizeof(skipcount),&skipcount); - iguana_rwnum(0,&request[len-4],sizeof(filter),&filter); + dragon_rwnum(0,&request[len-8],sizeof(skipcount),&skipcount); + dragon_rwnum(0,&request[len-4],sizeof(filter),&filter); } if ( 0 && isCC != 0 ) fprintf(stderr,"utxos %s isCC.%d skipcount.%d filter.%x\n",coinaddr,isCC,skipcount,filter); @@ -958,13 +958,13 @@ void komodo_nSPVreq(CNode *pfrom,std::vector request) // received a req else if ( request[1] == len-7 ) { isCC = (request[len-5] != 0); - iguana_rwnum(0,&request[len-4],sizeof(skipcount),&skipcount); + dragon_rwnum(0,&request[len-4],sizeof(skipcount),&skipcount); } else { isCC = (request[len-9] != 0); - iguana_rwnum(0,&request[len-8],sizeof(skipcount),&skipcount); - iguana_rwnum(0,&request[len-4],sizeof(filter),&filter); + dragon_rwnum(0,&request[len-8],sizeof(skipcount),&skipcount); + dragon_rwnum(0,&request[len-4],sizeof(filter),&filter); } if ( 0 && isCC != 0 ) fprintf(stderr,"txids %s isCC.%d skipcount.%d filter.%d\n",coinaddr,isCC,skipcount,filter); @@ -993,10 +993,10 @@ void komodo_nSPVreq(CNode *pfrom,std::vector request) // received a req { int32_t vout; uint256 txid; uint8_t funcid,isCC = 0; n = 1; - n += iguana_rwnum(0,&request[n],sizeof(isCC),&isCC); - n += iguana_rwnum(0,&request[n],sizeof(funcid),&funcid); - n += iguana_rwnum(0,&request[n],sizeof(vout),&vout); - n += iguana_rwbignum(0,&request[n],sizeof(txid),(uint8_t *)&txid); + n += dragon_rwnum(0,&request[n],sizeof(isCC),&isCC); + n += dragon_rwnum(0,&request[n],sizeof(funcid),&funcid); + n += dragon_rwnum(0,&request[n],sizeof(vout),&vout); + n += dragon_rwbignum(0,&request[n],sizeof(txid),(uint8_t *)&txid); slen = request[n++]; if ( slen < 63 ) { @@ -1028,7 +1028,7 @@ void komodo_nSPVreq(CNode *pfrom,std::vector request) // received a req struct NSPV_ntzsresp N; int32_t height; if ( len == 1+sizeof(height) ) { - iguana_rwnum(0,&request[1],sizeof(height),&height); + dragon_rwnum(0,&request[1],sizeof(height),&height); memset(&N,0,sizeof(N)); if ( (slen= NSPV_getntzsresp(&N,height)) > 0 ) { @@ -1051,8 +1051,8 @@ void komodo_nSPVreq(CNode *pfrom,std::vector request) // received a req struct NSPV_ntzsproofresp P; uint256 prevntz,nextntz; if ( len == 1+sizeof(prevntz)+sizeof(nextntz) ) { - iguana_rwbignum(0,&request[1],sizeof(prevntz),(uint8_t *)&prevntz); - iguana_rwbignum(0,&request[1+sizeof(prevntz)],sizeof(nextntz),(uint8_t *)&nextntz); + dragon_rwbignum(0,&request[1],sizeof(prevntz),(uint8_t *)&prevntz); + dragon_rwbignum(0,&request[1+sizeof(prevntz)],sizeof(nextntz),(uint8_t *)&nextntz); memset(&P,0,sizeof(P)); if ( (slen= NSPV_getntzsproofresp(&P,prevntz,nextntz)) > 0 ) { @@ -1076,9 +1076,9 @@ void komodo_nSPVreq(CNode *pfrom,std::vector request) // received a req struct NSPV_txproof P; uint256 txid; int32_t height,vout; if ( len == 1+sizeof(txid)+sizeof(height)+sizeof(vout) ) { - iguana_rwnum(0,&request[1],sizeof(height),&height); - iguana_rwnum(0,&request[1+sizeof(height)],sizeof(vout),&vout); - iguana_rwbignum(0,&request[1+sizeof(height)+sizeof(vout)],sizeof(txid),(uint8_t *)&txid); + dragon_rwnum(0,&request[1],sizeof(height),&height); + dragon_rwnum(0,&request[1+sizeof(height)],sizeof(vout),&vout); + dragon_rwbignum(0,&request[1+sizeof(height)+sizeof(vout)],sizeof(txid),(uint8_t *)&txid); //fprintf(stderr,"got txid %s/v%d ht.%d\n",txid.GetHex().c_str(),vout,height); memset(&P,0,sizeof(P)); if ( (slen= NSPV_gettxproof(&P,vout,txid,height)) > 0 ) @@ -1104,8 +1104,8 @@ void komodo_nSPVreq(CNode *pfrom,std::vector request) // received a req struct NSPV_spentinfo S; int32_t vout; uint256 txid; if ( len == 1+sizeof(txid)+sizeof(vout) ) { - iguana_rwnum(0,&request[1],sizeof(vout),&vout); - iguana_rwbignum(0,&request[1+sizeof(vout)],sizeof(txid),(uint8_t *)&txid); + dragon_rwnum(0,&request[1],sizeof(vout),&vout); + dragon_rwbignum(0,&request[1+sizeof(vout)],sizeof(txid),(uint8_t *)&txid); memset(&S,0,sizeof(S)); if ( (slen= NSPV_getspentinfo(&S,txid,vout)) > 0 ) { @@ -1128,8 +1128,8 @@ void komodo_nSPVreq(CNode *pfrom,std::vector request) // received a req struct NSPV_broadcastresp B; uint32_t n,offset; uint256 txid; if ( len > 1+sizeof(txid)+sizeof(n) ) { - iguana_rwbignum(0,&request[1],sizeof(txid),(uint8_t *)&txid); - iguana_rwnum(0,&request[1+sizeof(txid)],sizeof(n),&n); + dragon_rwbignum(0,&request[1],sizeof(txid),(uint8_t *)&txid); + dragon_rwnum(0,&request[1+sizeof(txid)],sizeof(n),&n); memset(&B,0,sizeof(B)); offset = 1 + sizeof(txid) + sizeof(n); if ( n < MAX_TX_SIZE_AFTER_SAPLING && request.size() == offset+n && (slen= NSPV_sendrawtransaction(&B,&request[offset],n)) > 0 ) @@ -1152,7 +1152,7 @@ void komodo_nSPVreq(CNode *pfrom,std::vector request) // received a req { struct NSPV_remoterpcresp R; int32_t p; p = 1; - p+=iguana_rwnum(0,&request[p],sizeof(slen),&slen); + p+=dragon_rwnum(0,&request[p],sizeof(slen),&slen); memset(&R,0,sizeof(R)); if (request.size() == p+slen && (slen=NSPV_remoterpc(&R,(char *)&request[p],slen))>0 ) { @@ -1191,9 +1191,9 @@ void komodo_nSPVreq(CNode *pfrom,std::vector request) // received a req memcpy(coinaddr, &request[n], addrlen); coinaddr[addrlen] = 0; n += addrlen; - iguana_rwnum(0, &request[n], sizeof(amount), &amount); + dragon_rwnum(0, &request[n], sizeof(amount), &amount); n += sizeof(amount); - iguana_rwnum(0, &request[n], sizeof(evalcode), &evalcode); + dragon_rwnum(0, &request[n], sizeof(evalcode), &evalcode); n += sizeof(evalcode); int32_t funcidslen = request[n++]; @@ -1202,7 +1202,7 @@ void komodo_nSPVreq(CNode *pfrom,std::vector request) // received a req memcpy(funcids, &request[n], funcidslen); funcids[funcidslen] = 0; n += funcidslen; - iguana_rwbignum(0, &request[n], sizeof(filtertxid), (uint8_t *)&filtertxid); + dragon_rwbignum(0, &request[n], sizeof(filtertxid), (uint8_t *)&filtertxid); std::cerr << __func__ << " " << "request addr=" << coinaddr << " amount=" << amount << " evalcode=" << (int)evalcode << " funcids=" << funcids << " filtertxid=" << filtertxid.GetHex() << std::endl; memset(&U, 0, sizeof(U)); diff --git a/src/komodo_nSPV_superlite.h b/src/komodo_nSPV_superlite.h index 3d56d44ba..6244359fd 100644 --- a/src/komodo_nSPV_superlite.h +++ b/src/komodo_nSPV_superlite.h @@ -293,7 +293,7 @@ void komodo_nSPV(CNode *pto) // polling loop from SendMessages reqht = 0; len = 0; msg[len++] = NSPV_INFO; - len += iguana_rwnum(1,&msg[len],sizeof(reqht),&reqht); + len += dragon_rwnum(1,&msg[len],sizeof(reqht),&reqht); //fprintf(stderr,"issue getinfo\n"); NSPV_req(pto,msg,len,NODE_NSPV,NSPV_INFO>>1); } @@ -556,7 +556,7 @@ UniValue NSPV_getinfo_req(int32_t reqht) uint8_t msg[512]; int32_t i,iter,len = 0; struct NSPV_inforesp I; NSPV_inforesp_purge(&NSPV_inforesult); msg[len++] = NSPV_INFO; - len += iguana_rwnum(1,&msg[len],sizeof(reqht),&reqht); + len += dragon_rwnum(1,&msg[len],sizeof(reqht),&reqht); for (iter=0; iter<3; iter++) if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 ) { @@ -609,8 +609,8 @@ UniValue NSPV_addressutxos(char *coinaddr,int32_t CCflag,int32_t skipcount,int32 msg[len++] = slen; memcpy(&msg[len],coinaddr,slen), len += slen; msg[len++] = (CCflag != 0); - len += iguana_rwnum(1,&msg[len],sizeof(skipcount),&skipcount); - len += iguana_rwnum(1,&msg[len],sizeof(filter),&filter); + len += dragon_rwnum(1,&msg[len],sizeof(skipcount),&skipcount); + len += dragon_rwnum(1,&msg[len],sizeof(filter),&filter); for (iter=0; iter<3; iter++) if ( NSPV_req(0,msg,len,NODE_ADDRINDEX,msg[0]>>1) != 0 ) { @@ -646,8 +646,8 @@ UniValue NSPV_addresstxids(char *coinaddr,int32_t CCflag,int32_t skipcount,int32 msg[len++] = slen; memcpy(&msg[len],coinaddr,slen), len += slen; msg[len++] = (CCflag != 0); - len += iguana_rwnum(1,&msg[len],sizeof(skipcount),&skipcount); - len += iguana_rwnum(1,&msg[len],sizeof(filter),&filter); + len += dragon_rwnum(1,&msg[len],sizeof(skipcount),&skipcount); + len += dragon_rwnum(1,&msg[len],sizeof(filter),&filter); //fprintf(stderr,"skipcount.%d\n",skipcount); for (iter=0; iter<3; iter++) if ( NSPV_req(0,msg,len,NODE_ADDRINDEX,msg[0]>>1) != 0 ) @@ -681,9 +681,9 @@ UniValue NSPV_ccaddresstxids(char *coinaddr,int32_t CCflag,int32_t skipcount,uin vout=skipcount << 16 | evalcode << 8 | func; msg[len++] = NSPV_MEMPOOL; msg[len++] = (CCflag != 0); - len += iguana_rwnum(1,&msg[len],sizeof(funcid),&funcid); - len += iguana_rwnum(1,&msg[len],sizeof(vout),&vout); - len += iguana_rwbignum(1,&msg[len],sizeof(filtertxid),(uint8_t *)&filtertxid); + len += dragon_rwnum(1,&msg[len],sizeof(funcid),&funcid); + len += dragon_rwnum(1,&msg[len],sizeof(vout),&vout); + len += dragon_rwbignum(1,&msg[len],sizeof(filtertxid),(uint8_t *)&filtertxid); slen = (int32_t)strlen(coinaddr); msg[len++] = slen; memcpy(&msg[len],coinaddr,slen), len += slen; @@ -719,9 +719,9 @@ UniValue NSPV_mempooltxids(char *coinaddr,int32_t CCflag,uint8_t funcid,uint256 } msg[len++] = NSPV_MEMPOOL; msg[len++] = (CCflag != 0); - len += iguana_rwnum(1,&msg[len],sizeof(funcid),&funcid); - len += iguana_rwnum(1,&msg[len],sizeof(vout),&vout); - len += iguana_rwbignum(1,&msg[len],sizeof(txid),(uint8_t *)&txid); + len += dragon_rwnum(1,&msg[len],sizeof(funcid),&funcid); + len += dragon_rwnum(1,&msg[len],sizeof(vout),&vout); + len += dragon_rwbignum(1,&msg[len],sizeof(txid),(uint8_t *)&txid); slen = (int32_t)strlen(coinaddr); msg[len++] = slen; memcpy(&msg[len],coinaddr,slen), len += slen; @@ -792,7 +792,7 @@ UniValue NSPV_notarizations(int32_t reqheight) return(NSPV_ntzsresp_json(ptr)); } msg[len++] = NSPV_NTZS; - len += iguana_rwnum(1,&msg[len],sizeof(reqheight),&reqheight); + len += dragon_rwnum(1,&msg[len],sizeof(reqheight),&reqheight); for (iter=0; iter<3; iter++) if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 ) { @@ -819,8 +819,8 @@ UniValue NSPV_txidhdrsproof(uint256 prevtxid,uint256 nexttxid) } NSPV_ntzsproofresp_purge(&NSPV_ntzsproofresult); msg[len++] = NSPV_NTZSPROOF; - len += iguana_rwbignum(1,&msg[len],sizeof(prevtxid),(uint8_t *)&prevtxid); - len += iguana_rwbignum(1,&msg[len],sizeof(nexttxid),(uint8_t *)&nexttxid); + len += dragon_rwbignum(1,&msg[len],sizeof(prevtxid),(uint8_t *)&prevtxid); + len += dragon_rwbignum(1,&msg[len],sizeof(nexttxid),(uint8_t *)&nexttxid); for (iter=0; iter<3; iter++) if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 ) { @@ -857,9 +857,9 @@ UniValue NSPV_txproof(int32_t vout,uint256 txid,int32_t height) } NSPV_txproof_purge(&NSPV_txproofresult); msg[len++] = NSPV_TXPROOF; - len += iguana_rwnum(1,&msg[len],sizeof(height),&height); - len += iguana_rwnum(1,&msg[len],sizeof(vout),&vout); - len += iguana_rwbignum(1,&msg[len],sizeof(txid),(uint8_t *)&txid); + len += dragon_rwnum(1,&msg[len],sizeof(height),&height); + len += dragon_rwnum(1,&msg[len],sizeof(vout),&vout); + len += dragon_rwbignum(1,&msg[len],sizeof(txid),(uint8_t *)&txid); fprintf(stderr,"req txproof %s/v%d at height.%d\n",txid.GetHex().c_str(),vout,height); for (iter=0; iter<3; iter++) if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 ) @@ -881,8 +881,8 @@ UniValue NSPV_spentinfo(uint256 txid,int32_t vout) uint8_t msg[512]; int32_t i,iter,len = 0; struct NSPV_spentinfo I; NSPV_spentinfo_purge(&NSPV_spentresult); msg[len++] = NSPV_SPENTINFO; - len += iguana_rwnum(1,&msg[len],sizeof(vout),&vout); - len += iguana_rwbignum(1,&msg[len],sizeof(txid),(uint8_t *)&txid); + len += dragon_rwnum(1,&msg[len],sizeof(vout),&vout); + len += dragon_rwbignum(1,&msg[len],sizeof(txid),(uint8_t *)&txid); for (iter=0; iter<3; iter++) if ( NSPV_req(0,msg,len,NODE_SPENTINDEX,msg[0]>>1) != 0 ) { @@ -907,8 +907,8 @@ UniValue NSPV_broadcast(char *hex) txid = NSPV_doublesha256(data,n); msg = (uint8_t *)malloc(1 + sizeof(txid) + sizeof(n) + n); msg[len++] = NSPV_BROADCAST; - len += iguana_rwbignum(1,&msg[len],sizeof(txid),(uint8_t *)&txid); - len += iguana_rwnum(1,&msg[len],sizeof(n),&n); + len += dragon_rwbignum(1,&msg[len],sizeof(txid),(uint8_t *)&txid); + len += dragon_rwnum(1,&msg[len],sizeof(n),&n); memcpy(&msg[len],data,n), len += n; free(data); //fprintf(stderr,"send txid.%s\n",txid.GetHex().c_str()); @@ -953,14 +953,14 @@ UniValue NSPV_ccmoduleutxos(char *coinaddr, int64_t amount, uint8_t evalcode, st msg[len++] = slen; memcpy(&msg[len], coinaddr, slen), len += slen; - len += iguana_rwnum(1, &msg[len], sizeof(amount), &amount); - len += iguana_rwnum(1, &msg[len], sizeof(evalcode), &evalcode); + len += dragon_rwnum(1, &msg[len], sizeof(amount), &amount); + len += dragon_rwnum(1, &msg[len], sizeof(evalcode), &evalcode); slen = (int32_t)(funcids.size()); msg[len++] = slen; memcpy(&msg[len], funcids.data(), slen), len += slen; - len += iguana_rwbignum(1, &msg[len], sizeof(filtertxid), (uint8_t *)&filtertxid); + len += dragon_rwbignum(1, &msg[len], sizeof(filtertxid), (uint8_t *)&filtertxid); for (iter = 0; iter<3; iter++) if (NSPV_req(0, msg, len, NODE_ADDRINDEX, msg[0] >> 1) != 0) { diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 9935f3463..787295a0f 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -197,16 +197,16 @@ int32_t dpow_readprices(int32_t height,uint8_t *data,uint32_t *timestampp,double uint32_t kmdbtc,btcusd,cnyusd; int32_t i,n,nonz,len = 0; if ( data[0] == 'P' && data[5] == 35 ) data++; - len += iguana_rwnum(0,&data[len],sizeof(uint32_t),(void *)timestampp); - len += iguana_rwnum(0,&data[len],sizeof(uint32_t),(void *)&n); + len += dragon_rwnum(0,&data[len],sizeof(uint32_t),(void *)timestampp); + len += dragon_rwnum(0,&data[len],sizeof(uint32_t),(void *)&n); if ( n != 35 ) { printf("dpow_readprices illegal n.%d\n",n); return(-1); } - len += iguana_rwnum(0,&data[len],sizeof(uint32_t),(void *)&kmdbtc); // /= 1000 - len += iguana_rwnum(0,&data[len],sizeof(uint32_t),(void *)&btcusd); // *= 1000 - len += iguana_rwnum(0,&data[len],sizeof(uint32_t),(void *)&cnyusd); + len += dragon_rwnum(0,&data[len],sizeof(uint32_t),(void *)&kmdbtc); // /= 1000 + len += dragon_rwnum(0,&data[len],sizeof(uint32_t),(void *)&btcusd); // *= 1000 + len += dragon_rwnum(0,&data[len],sizeof(uint32_t),(void *)&cnyusd); *KMDBTCp = ((double)kmdbtc / (1000000000. * 1000.)); *BTCUSDp = PAX_BTCUSD(height,btcusd); *CNYUSDp = ((double)cnyusd / 1000000000.); @@ -216,7 +216,7 @@ int32_t dpow_readprices(int32_t height,uint8_t *data,uint32_t *timestampp,double nonz++; //else if ( nonz != 0 ) // printf("pvals[%d] is zero\n",i); - len += iguana_rwnum(0,&data[len],sizeof(uint32_t),(void *)&pvals[i]); + len += dragon_rwnum(0,&data[len],sizeof(uint32_t),(void *)&pvals[i]); //printf("%u ",pvals[i]); } /*if ( nonz < n-3 ) @@ -249,7 +249,7 @@ int32_t komodo_pax_opreturn(int32_t height,uint8_t *opret,int32_t maxsize) { if ( (retval= (int32_t)fread(data,1,fsize,fp)) == fsize ) { - len = iguana_rwnum(0,data,sizeof(crc32),(void *)&crc32); + len = dragon_rwnum(0,data,sizeof(crc32),(void *)&crc32); check = calc_crc32(0,data+sizeof(crc32),(int32_t)(fsize-sizeof(crc32))); if ( check == crc32 ) { @@ -301,7 +301,7 @@ int32_t PAX_pubkey(int32_t rwflag,uint8_t *pubkey33,uint8_t *addrtypep,uint8_t r memset(pubkey33,0,33); pubkey33[0] = 0x02 | (*shortflagp != 0); memcpy(&pubkey33[1],fiat,3); - iguana_rwnum(rwflag,&pubkey33[4],sizeof(*fiatoshisp),(void *)fiatoshisp); + dragon_rwnum(rwflag,&pubkey33[4],sizeof(*fiatoshisp),(void *)fiatoshisp); pubkey33[12] = *addrtypep; memcpy(&pubkey33[13],rmd160,20); } @@ -310,7 +310,7 @@ int32_t PAX_pubkey(int32_t rwflag,uint8_t *pubkey33,uint8_t *addrtypep,uint8_t r *shortflagp = (pubkey33[0] == 0x03); memcpy(fiat,&pubkey33[1],3); fiat[3] = 0; - iguana_rwnum(rwflag,&pubkey33[4],sizeof(*fiatoshisp),(void *)fiatoshisp); + dragon_rwnum(rwflag,&pubkey33[4],sizeof(*fiatoshisp),(void *)fiatoshisp); if ( *shortflagp != 0 ) *fiatoshisp = -(*fiatoshisp); *addrtypep = pubkey33[12]; diff --git a/src/komodo_port.c b/src/komodo_port.c index fd68db881..fe05b0e3f 100644 --- a/src/komodo_port.c +++ b/src/komodo_port.c @@ -727,7 +727,7 @@ void calc_rmd160_sha256(uint8_t rmd160[20],uint8_t *data,int32_t datalen) calc_rmd160(0,rmd160,hash.bytes,sizeof(hash)); } -int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp) +int32_t dragon_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp) { int32_t i; uint64_t x; if ( rwflag == 0 ) @@ -767,7 +767,7 @@ uint32_t komodo_assetmagic(char *symbol,uint64_t supply,uint8_t *extraptr,int32_ uint8_t buf[512]; uint32_t crc0=0; int32_t len = 0; bits256 hash; if ( strcmp(symbol,"KMD") == 0 ) return(0x8de4eef9); - len = iguana_rwnum(1,&buf[len],sizeof(supply),(void *)&supply); + len = dragon_rwnum(1,&buf[len],sizeof(supply),(void *)&supply); strcpy((char *)&buf[len],symbol); len += strlen(symbol); if ( extraptr != 0 && extralen != 0 ) @@ -821,12 +821,12 @@ uint16_t komodo_calcport(char *name,uint64_t supply,uint64_t endsubsidy,uint64_t //printf("end.%llu reward.%llu halving.%llu decay.%llu perc.%llu\n",(long long)endsubsidy,(long long)reward,(long long)halving,(long long)decay,(long long)commission); extraptr = extrabuf; memcpy(extraptr,ASSETCHAINS_OVERRIDE_PUBKEY33,33), extralen = 33; - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(endsubsidy),(void *)&endsubsidy); - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(reward),(void *)&reward); - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(halving),(void *)&halving); - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(decay),(void *)&decay); + extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(endsubsidy),(void *)&endsubsidy); + extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(reward),(void *)&reward); + extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(halving),(void *)&halving); + extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(decay),(void *)&decay); val = commission | (((uint64_t)staked & 0xff) << 32) | (((uint64_t)cc & 0xffffff) << 40); - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val); + extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val); } return(komodo_port(name,supply,&ASSETCHAINS_MAGIC,extraptr,extralen)); } diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 2e4e679ca..ff55c2833 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -927,7 +927,7 @@ char *bits256_str(char hexstr[65],bits256 x) return(hexstr); } -int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp) +int32_t dragon_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp) { int32_t i; uint64_t x; if ( rwflag == 0 ) @@ -962,7 +962,7 @@ int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endian return(len); } -int32_t iguana_rwbignum(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *endianedp) +int32_t dragon_rwbignum(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *endianedp) { int32_t i; if ( rwflag == 0 ) @@ -1282,7 +1282,7 @@ int32_t queue_size(queue_t *queue) return count; } -void iguana_initQ(queue_t *Q,char *name) +void dragon_initQ(queue_t *Q,char *name) { struct queueitem *item,*I; memset(Q,0,sizeof(*Q)); @@ -1465,7 +1465,7 @@ uint32_t komodo_assetmagic(char *symbol,uint64_t supply,uint8_t *extraptr,int32_ uint8_t buf[512]; uint32_t crc0=0; int32_t len = 0; bits256 hash; if ( strcmp(symbol,"KMD") == 0 ) return(0x8de4eef9); - len = iguana_rwnum(1,&buf[len],sizeof(supply),(void *)&supply); + len = dragon_rwnum(1,&buf[len],sizeof(supply),(void *)&supply); strcpy((char *)&buf[len],symbol); len += strlen(symbol); if ( extraptr != 0 && extralen != 0 ) @@ -1510,7 +1510,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,\\\"notarypay\\\":%i}\""; +char *dragonfmtstr = (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\\\":\\\"dragon\\\",\\\"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,\\\"notarypay\\\":%i}\""; @@ -2162,58 +2162,58 @@ void komodo_args(char *argv0) (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 += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_ENDSUBSIDY[i]),(void *)&ASSETCHAINS_ENDSUBSIDY[i]); + extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_REWARD[i]),(void *)&ASSETCHAINS_REWARD[i]); + extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_HALVING[i]),(void *)&ASSETCHAINS_HALVING[i]); + extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_DECAY[i]),(void *)&ASSETCHAINS_DECAY[i]); if ( ASSETCHAINS_NOTARY_PAY[0] != 0 ) - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NOTARY_PAY[i]),(void *)&ASSETCHAINS_NOTARY_PAY[i]); + extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NOTARY_PAY[i]),(void *)&ASSETCHAINS_NOTARY_PAY[i]); } if (ASSETCHAINS_LASTERA > 0) { - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_LASTERA),(void *)&ASSETCHAINS_LASTERA); + extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_LASTERA),(void *)&ASSETCHAINS_LASTERA); } // hash in lock above for time locked coinbase transactions above a certain reward value only if the lock above // param was specified, otherwise, for compatibility, do nothing if ( ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF ) { - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_TIMELOCKGTE),(void *)&ASSETCHAINS_TIMELOCKGTE); - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_TIMEUNLOCKFROM),(void *)&ASSETCHAINS_TIMEUNLOCKFROM); - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_TIMEUNLOCKTO),(void *)&ASSETCHAINS_TIMEUNLOCKTO); + extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_TIMELOCKGTE),(void *)&ASSETCHAINS_TIMELOCKGTE); + extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_TIMEUNLOCKFROM),(void *)&ASSETCHAINS_TIMEUNLOCKFROM); + extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_TIMEUNLOCKTO),(void *)&ASSETCHAINS_TIMEUNLOCKTO); } if ( ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH ) { - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_ALGO),(void *)&ASSETCHAINS_ALGO); + extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_ALGO),(void *)&ASSETCHAINS_ALGO); } if ( ASSETCHAINS_LWMAPOS != 0 ) { - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_LWMAPOS),(void *)&ASSETCHAINS_LWMAPOS); + extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_LWMAPOS),(void *)&ASSETCHAINS_LWMAPOS); } 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); + extralen += dragon_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); + extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(tmp),(void *)&tmp); if ( ASSETCHAINS_FOUNDERS > 1 ) - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS),(void *)&ASSETCHAINS_FOUNDERS); + extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS),(void *)&ASSETCHAINS_FOUNDERS); if ( ASSETCHAINS_FOUNDERS_REWARD != 0 ) { fprintf(stderr, "set founders reward.%lld\n",(long long)ASSETCHAINS_FOUNDERS_REWARD); - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS_REWARD),(void *)&ASSETCHAINS_FOUNDERS_REWARD); + extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS_REWARD),(void *)&ASSETCHAINS_FOUNDERS_REWARD); } } if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) { decode_hex(&extraptr[extralen],ASSETCHAINS_SCRIPTPUB.size()/2,(char *)ASSETCHAINS_SCRIPTPUB.c_str()); extralen += ASSETCHAINS_SCRIPTPUB.size()/2; - //extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); + //extralen += dragon_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); fprintf(stderr,"append ac_script %s\n",ASSETCHAINS_SCRIPTPUB.c_str()); } if ( ASSETCHAINS_SELFIMPORT.size() > 0 ) @@ -2246,7 +2246,7 @@ fprintf(stderr,"extralen.%d before disable bits\n",extralen); fprintf(stderr," <- CCLIB name\n"); } if ( ASSETCHAINS_BLOCKTIME != 60 ) - extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_BLOCKTIME),(void *)&ASSETCHAINS_BLOCKTIME); + extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_BLOCKTIME),(void *)&ASSETCHAINS_BLOCKTIME); if ( Mineropret.size() != 0 ) { for (i=0; i 0: - for obj in KMD: - #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']: - 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) diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 0750ed129..654c0262e 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -98,10 +98,10 @@ int32_t getera(int timestamp) return(0); } -UniValue getiguanajson(const UniValue& params, bool fHelp, const CPubKey& mypk) +UniValue getdragonjson(const UniValue& params, bool fHelp, const CPubKey& mypk) { if (fHelp || params.size() != 0) - throw runtime_error("getiguanajson\nreturns json for iguana, for the current ERA."); + throw runtime_error("getdragonjson\nreturns json for dragon, for the current ERA."); UniValue json(UniValue::VOBJ); UniValue seeds(UniValue::VARR); @@ -113,7 +113,7 @@ UniValue getiguanajson(const UniValue& params, bool fHelp, const CPubKey& mypk) // 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]); + seeds.push_back(dragonSeeds[i][0]); } // loop over era's notaries and push back each pair to the notary array @@ -123,14 +123,14 @@ UniValue getiguanajson(const UniValue& params, bool fHelp, const CPubKey& mypk) notaries.push_back(notary); } - // get the min sigs .. this always rounds UP so min 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 dragon 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("port",dragonPort)); json.push_back(Pair("BTCminsigs",BTCminsigs)); json.push_back(Pair("minsigs",minsigs)); json.push_back(Pair("seeds",seeds)); @@ -207,8 +207,8 @@ UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk) " \"balance\": xxxxxxx, (numeric) the total Hush balance of the wallet\n" " \"blocks\": xxxxxx, (numeric) the current number of blocks processed in the server\n" " \"timeoffset\": xxxxx, (numeric) the time offset (deprecated, always 0)\n" - " \"connections\": xxxxx, (numeric) the number of connections\n" - " \"tls_connections\": xxxxx, (numeric) the number of TLS connections\n" + " \"connections\": xxxxx, (numeric) the number of plaintext connections\n" + " \"tls_connections\": xxxxx, (numeric) the number of encrypted TLS (SSL) connections\n" " \"proxy\": \"host:port\", (string, optional) the proxy used by the server\n" " \"difficulty\": xxxxxx, (numeric) the current difficulty\n" " \"testnet\": true|false, (boolean) if the server is using testnet or not\n" @@ -237,8 +237,11 @@ UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk) 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)); + // this KMD version represents the last time we did a full merge, we only cherry-pick or take nothing + // in the post-KYC "era" of KMD + obj.push_back(Pair("KMDversion", KOMODO_VERSION)); // never change this again, it's set in stone. -- Duke obj.push_back(Pair("synced", KOMODO_INSYNC!=0)); + // any height larger than this can be attacked! obj.push_back(Pair("notarized", notarized_height)); obj.push_back(Pair("prevMoMheight", prevMoMheight)); obj.push_back(Pair("notarizedhash", notarized_hash.ToString())); @@ -477,64 +480,6 @@ UniValue coinsupply(const UniValue& params, bool fHelp, const CPubKey& mypk) return(result); } -UniValue jumblr_deposit(const UniValue& params, bool fHelp, const CPubKey& mypk) -{ - 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, const CPubKey& mypk) -{ - 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, const CPubKey& mypk) -{ - 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, const CPubKey& mypk) -{ - 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, const CPubKey& mypk) { if (fHelp || params.size() != 1) diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 22c8c7eae..aa5375d94 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -298,7 +298,7 @@ static const CRPCCommand vRPCCommands[] = // --------------------- ------------------------ ----------------------- ---------- /* Overall control/query calls */ { "control", "help", &help, true }, - { "control", "getiguanajson", &getiguanajson, true }, + { "control", "getdragonjson", &getdragonjson, true }, { "control", "getnotarysendmany", &getnotarysendmany, true }, { "control", "geterablockheights", &geterablockheights, true }, { "control", "stop", &stop, true }, @@ -594,15 +594,11 @@ static const CRPCCommand vRPCCommands[] = { "util", "estimatefee", &estimatefee, true }, { "util", "estimatepriority", &estimatepriority, true }, { "util", "z_validateaddress", &z_validateaddress, true }, /* uses wallet if enabled */ - { "util", "jumblr_deposit", &jumblr_deposit, true }, - { "util", "jumblr_secret", &jumblr_secret, true }, - { "util", "jumblr_pause", &jumblr_pause, true }, - { "util", "jumblr_resume", &jumblr_resume, true }, - - { "util", "invalidateblock", &invalidateblock, true }, - { "util", "reconsiderblock", &reconsiderblock, true }, - /* Not shown in help */ - { "hidden", "setmocktime", &setmocktime, true }, + { "util", "invalidateblock", &invalidateblock, true }, + { "util", "reconsiderblock", &reconsiderblock, true }, + /* Fuck not showing users all the options -- Duke */ + /* setmocktime used to Not be shown in help */ + { "util", "setmocktime", &setmocktime, true }, #ifdef ENABLE_WALLET diff --git a/src/rpc/server.h b/src/rpc/server.h index 69c50add3..65422ab1b 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -391,7 +391,7 @@ extern UniValue validateaddress(const UniValue& params, bool fHelp, const CPubKe extern UniValue txnotarizedconfirmed(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue decodeccopret(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk); -extern UniValue getiguanajson(const UniValue& params, bool fHelp, const CPubKey& mypk); +extern UniValue getdragonjson(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue getnotarysendmany(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue geterablockheights(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue setpubkey(const UniValue& params, bool fHelp, const CPubKey& mypk); @@ -403,11 +403,6 @@ extern UniValue getdeprecationinfo(const UniValue& params, bool fHelp, const CPu extern UniValue setmocktime(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue resendwallettransactions(const UniValue& params, bool fHelp, const CPubKey& mypk); -extern UniValue jumblr_deposit(const UniValue& params, bool fHelp, const CPubKey& mypk); -extern UniValue jumblr_secret(const UniValue& params, bool fHelp, const CPubKey& mypk); -extern UniValue jumblr_pause(const UniValue& params, bool fHelp, const CPubKey& mypk); -extern UniValue jumblr_resume(const UniValue& params, bool fHelp, const CPubKey& mypk); - extern UniValue getrawtransaction(const UniValue& params, bool fHelp, const CPubKey& mypk); // in rcprawtransaction.cpp extern UniValue listunspent(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue lockunspent(const UniValue& params, bool fHelp, const CPubKey& mypk); diff --git a/src/fiat/hush b/src/sc/hush similarity index 68% rename from src/fiat/hush rename to src/sc/hush index 3d7a3425d..9ac3edcd4 100755 --- a/src/fiat/hush +++ b/src/sc/hush @@ -1,7 +1,7 @@ #!/bin/bash - +# Copyright (c) 2018-2020 The Hush developers #set working directory to the location of this script DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" cd $DIR -../komodo-cli -ac_name=HUSH3 "$@" +../hush-cli $@ diff --git a/src/sc/koolaid b/src/sc/koolaid new file mode 100755 index 000000000..5c3543ecf --- /dev/null +++ b/src/sc/koolaid @@ -0,0 +1,3 @@ +#!/bin/bash +# Copyright (c) 2018-2020 The Hush developers +./hush-smart-chain -ac_name=KOOLAID $@ diff --git a/src/sc/kush b/src/sc/kush new file mode 100755 index 000000000..b39a0d5fd --- /dev/null +++ b/src/sc/kush @@ -0,0 +1,3 @@ +#!/bin/bash +# Copyright (c) 2018-2020 The Hush developers +./hush-smart-chain -ac_name=KUSH $@ diff --git a/src/sc/zex b/src/sc/zex new file mode 100755 index 000000000..2c95cf1a9 --- /dev/null +++ b/src/sc/zex @@ -0,0 +1,3 @@ +#!/bin/bash +# Copyright (c) 2018-2020 The Hush developers +./hush-smart-chain -ac_name=ZEX $@ diff --git a/src/assetchains b/src/smartchains similarity index 63% rename from src/assetchains rename to src/smartchains index 0469fa728..5dd954c12 100755 --- a/src/assetchains +++ b/src/smartchains @@ -1,11 +1,12 @@ #!/bin/bash +# Copyright (c) 2018-2020 The Hush developers set -eo pipefail # You can now add delay line to pubkey.txt file source pubkey.txt overide_args="$@" -seed_ip=`getent hosts zero.kolo.supernet.org | awk '{ print $1 }'` -komodo_binary='./komodod' +seed_ip=$(SEEDNODE) +hsc='./hush-smart-chain' if [ -z "$delay" ]; then delay=20; fi @@ -15,6 +16,6 @@ if [ -z "$delay" ]; then delay=20; fi gen=" -gen -genproclimit=1" fi - $komodo_binary $gen $args $overide_args -pubkey=$pubkey -addnode=$seed_ip & + $hsc $gen $args $overide_args -pubkey=$pubkey -addnode=$seed_ip & sleep $delay done diff --git a/src/smartchains.json b/src/smartchains.json new file mode 100644 index 000000000..9e71fa4db --- /dev/null +++ b/src/smartchains.json @@ -0,0 +1,22 @@ +[ + { + "ac_name": "HUSH3", + "ac_sapling": "1", + "ac_founders": "1", + "ac_reward": "0,1125000000,562500000", + "ac_end": "128,340000,5422111", + "ac_blocktime": "150", + "ac_supply": "6178674", + "ac_halving": "129,340000,840000", + "ac_cc": "2", + "ac_cclib": "hush3", + "ac_ccenable": "228,234,235,236,241", + "ac_perc": "11111111", + "ac_eras": "3", + "ac_script": "76a9145eb10cf64f2bab1b457f1f25e658526155928fac88ac", + "clientname": "GoldenSandtrout", + "addnode": [ + "1.1.1.1" + ] + } +] diff --git a/src/smartchains.old b/src/smartchains.old new file mode 100755 index 000000000..3a369677f --- /dev/null +++ b/src/smartchains.old @@ -0,0 +1,17 @@ +#!/bin/bash +# Copyright (c) 2018-2020 The Hush developers +set -x +delay=60 +source pubkey.txt +echo $pubkey +echo "jl777 is a traitor to his village of cypherpunks, ca333 is his obedient servant" + +hsc="./hush-smart-chain" +ip=$(HUSHDEX_SEEDNODE) + +# this chain helps power HushDEX +$hsc -pubkey=$pubkey -ac_name=ZEX -ac_supply=100000000 -addnode=$ip $@ & + +# these are testcoins, like ARRR +$hsc -pubkey=$pubkey -ac_name=ZUSH -ac_supply=100000000 -addnode=$ip $@ & +$hsc -pubkey=$pubkey -ac_name=KOOLAID -ac_supply=100000000 -addnode=$ip $@ & diff --git a/src/tui/LICENSE b/src/tui/LICENSE deleted file mode 100644 index 3300ef648..000000000 --- a/src/tui/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -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 deleted file mode 100644 index 61e733794..000000000 --- a/src/tui/README.md +++ /dev/null @@ -1,58 +0,0 @@ -# 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 deleted file mode 100644 index 15ace1ad5..000000000 --- a/src/tui/lib/logo.txt +++ /dev/null @@ -1,39 +0,0 @@ -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 deleted file mode 100644 index a79fc73d4..000000000 --- a/src/tui/lib/rpclib.py +++ /dev/null @@ -1,129 +0,0 @@ -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 deleted file mode 100755 index afb4fad63..000000000 --- a/src/tui/lib/tuilib.py +++ /dev/null @@ -1,1992 +0,0 @@ -from lib import rpclib -import json -import time -import re -import sys -import pickle -import platform -import os -import subprocess -import random -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 - - -class CustomProxy(Proxy): - def __init__(self, - service_url=None, - service_port=None, - conf_file=None, - timeout=3000): - config = dict() - if conf_file: - config = slickrpc.ConfigObj(conf_file) - if service_url: - config.update(self.url_to_conf(service_url)) - if service_port: - config.update(rpcport=service_port) - elif not config.get('rpcport'): - config['rpcport'] = 7771 - self.conn = self.prepare_connection(config, timeout=timeout) - - -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(CustomProxy("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: - 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: - 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 - 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: - 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 < 1: - 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) - 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"]) - 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 deleted file mode 100644 index 734da529c..000000000 --- a/src/tui/requirements.txt +++ /dev/null @@ -1,8 +0,0 @@ -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 deleted file mode 100755 index 091484a40..000000000 --- a/src/tui/tui_assets.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/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 deleted file mode 100755 index 7bb489c7f..000000000 --- a/src/tui/tui_gateways_creation.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/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 deleted file mode 100755 index 0c989e3af..000000000 --- a/src/tui/tui_gateways_usage.py +++ /dev/null @@ -1,96 +0,0 @@ -#!/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 deleted file mode 100755 index cfe628890..000000000 --- a/src/tui/tui_marmara.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/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 deleted file mode 100755 index fec874d35..000000000 --- a/src/tui/tui_oracles.py +++ /dev/null @@ -1,67 +0,0 @@ -#!/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 deleted file mode 100755 index 9942369e2..000000000 --- a/src/tui/tui_rogue.py +++ /dev/null @@ -1,116 +0,0 @@ -#!/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 deleted file mode 100755 index 3c42d4daa..000000000 --- a/src/tui/tui_tetris.py +++ /dev/null @@ -1,96 +0,0 @@ -#!/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() diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f98abe2a1..29f1a15ee 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -587,7 +587,7 @@ int32_t komodo_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_ extern int32_t KOMODO_PAX; extern uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; int32_t komodo_is_issuer(); -int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp); +int32_t dragon_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp); int32_t komodo_isrealtime(int32_t *kmdheightp); 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 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); @@ -703,10 +703,10 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk) ret.push_back(Pair("value",params[1].get_str())); ret.push_back(Pair("valuesize",valuesize)); } - iguana_rwnum(1,&keyvalue[0],sizeof(keylen),&keylen); - iguana_rwnum(1,&keyvalue[2],sizeof(valuesize),&valuesize); - iguana_rwnum(1,&keyvalue[4],sizeof(height),&height); - iguana_rwnum(1,&keyvalue[8],sizeof(flags),&flags); + dragon_rwnum(1,&keyvalue[0],sizeof(keylen),&keylen); + dragon_rwnum(1,&keyvalue[2],sizeof(valuesize),&valuesize); + dragon_rwnum(1,&keyvalue[4],sizeof(height),&height); + dragon_rwnum(1,&keyvalue[8],sizeof(flags),&flags); memcpy(&keyvalue[12],key,keylen); if ( value != 0 ) memcpy(&keyvalue[12 + keylen],value,valuesize); @@ -780,7 +780,7 @@ UniValue paxdeposit(const UniValue& params, bool fHelp, const CPubKey& mypk) uint8_t opretbuf[64]; int32_t opretlen; uint64_t fee = komodoshis / 1000; if ( fee < 10000 ) fee = 10000; - iguana_rwnum(1,&pubkey37[33],sizeof(height),&height); + dragon_rwnum(1,&pubkey37[33],sizeof(height),&height); opretlen = komodo_opreturnscript(opretbuf,'D',pubkey37,37); SendMoney(address.Get(),fee,fSubtractFeeFromAmount,wtx,opretbuf,opretlen,komodoshis); return wtx.GetHash().GetHex(); @@ -815,7 +815,7 @@ UniValue paxwithdraw(const UniValue& params, bool fHelp, const CPubKey& mypk) uint8_t opretbuf[64]; int32_t opretlen; uint64_t fee = fiatoshis / 1000; if ( fee < 10000 ) fee = 10000; - iguana_rwnum(1,&pubkey37[33],sizeof(kmdheight),&kmdheight); + dragon_rwnum(1,&pubkey37[33],sizeof(kmdheight),&kmdheight); opretlen = komodo_opreturnscript(opretbuf,'W',pubkey37,37); SendMoney(destaddress.Get(),fee,fSubtractFeeFromAmount,wtx,opretbuf,opretlen,fiatoshis); return wtx.GetHash().GetHex(); @@ -5196,7 +5196,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp + 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 Sapling Notes", 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 10,000 sat p2pk utxo that iguana uses, and merges coinbase 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 dragon 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" diff --git a/src/zcash/JoinSplit.cpp b/src/zcash/JoinSplit.cpp index f4d558459..f4690f5dd 100644 --- a/src/zcash/JoinSplit.cpp +++ b/src/zcash/JoinSplit.cpp @@ -5,21 +5,10 @@ #include "prf.h" #include "sodium.h" -#include "zcash/util.h" - #include - -#include -#include -#include #include -#include "tinyformat.h" -#include "sync.h" -#include "amount.h" #include "librustzcash.h" -#include "streams.h" -#include "version.h" namespace libzcash { diff --git a/src/zcash/JoinSplit.hpp b/src/zcash/JoinSplit.hpp index 8193ba1bf..ceac79fe4 100644 --- a/src/zcash/JoinSplit.hpp +++ b/src/zcash/JoinSplit.hpp @@ -11,7 +11,6 @@ #include "Note.hpp" #include "IncrementalMerkleTree.hpp" #include "NoteEncryption.hpp" - #include "uint256.h" #include "uint252.h" @@ -27,19 +26,15 @@ static constexpr size_t GROTH_PROOF_SIZE = ( typedef std::array GrothProof; typedef boost::variant SproutProof; -class JSInput { -}; +class JSInput { }; -class JSOutput { -}; +class JSOutput { }; template -class JoinSplit { -}; +class JoinSplit { }; } -typedef libzcash::JoinSplit ZCJoinSplit; +typedef libzcash::JoinSplit ZCJoinSplit; #endif // ZC_JOINSPLIT_H_