Browse Source

Merge branch 'danger' into duke

pull/305/head
Duke Leto 4 years ago
parent
commit
52d02c2e6d
  1. 2
      CONTRIBUTING.md
  2. 72
      makeReleaseMac.sh
  3. 12
      resolve.sh
  4. 2
      src/ac/axo
  5. 2
      src/ac/beer
  6. 2
      src/ac/bet
  7. 2
      src/ac/bntn
  8. 2
      src/ac/bots
  9. 2
      src/ac/btch
  10. 2
      src/ac/ccl
  11. 2
      src/ac/ceal
  12. 2
      src/ac/chain
  13. 2
      src/ac/coquicash
  14. 2
      src/ac/crypto
  15. 2
      src/ac/dex
  16. 2
      src/ac/dion
  17. 2
      src/ac/dsec
  18. 2
      src/ac/eql
  19. 2
      src/ac/etomic
  20. 2
      src/ac/glxt
  21. 2
      src/ac/hodl
  22. 3
      src/ac/ilien
  23. 2
      src/ac/iln
  24. 2
      src/ac/jumblr
  25. 2
      src/ac/k64
  26. 2
      src/ac/kmdice
  27. 2
      src/ac/koin
  28. 2
      src/ac/ksb
  29. 2
      src/ac/kv
  30. 2
      src/ac/mesh
  31. 2
      src/ac/mgnx
  32. 2
      src/ac/mgw
  33. 2
      src/ac/mnz
  34. 2
      src/ac/morty
  35. 2
      src/ac/mshark
  36. 2
      src/ac/ninja
  37. 2
      src/ac/oot
  38. 2
      src/ac/our
  39. 2
      src/ac/pangea
  40. 2
      src/ac/pgt
  41. 2
      src/ac/pirate
  42. 2
      src/ac/pizza
  43. 2
      src/ac/prlpay
  44. 2
      src/ac/revs
  45. 2
      src/ac/rick
  46. 2
      src/ac/supernet
  47. 2
      src/ac/thc
  48. 2
      src/ac/vote2018
  49. 2
      src/ac/vote2019
  50. 2
      src/ac/wlc
  51. 2
      src/ac/zexo
  52. 337
      src/assetchains.json
  53. 55
      src/assetchains.old
  54. 4
      src/cc/CCinclude.h
  55. 44
      src/cc/crypto777/OS_portable.h
  56. 17
      src/cc/dapps/Makefile
  57. 52
      src/cc/dapps/README.md
  58. 9
      src/cc/dapps/dappinc.h
  59. 370
      src/cc/dapps/hushdex.c
  60. 19
      src/cc/dapps/hushdex.json
  61. 1151
      src/cc/dapps/oraclefeed.c
  62. 27
      src/cc/dapps/subatomic.json
  63. 4
      src/cc/includes/curve25519.h
  64. 14
      src/cc/oracles.cpp
  65. 9
      src/fiat-cli
  66. 2
      src/fiat/axo
  67. 2
      src/fiat/beer
  68. 2
      src/fiat/bet
  69. 2
      src/fiat/bntn
  70. 2
      src/fiat/bots
  71. 2
      src/fiat/btch
  72. 2
      src/fiat/ccl
  73. 2
      src/fiat/ceal
  74. 2
      src/fiat/chain
  75. 2
      src/fiat/coquicash
  76. 2
      src/fiat/crypto
  77. 2
      src/fiat/dex
  78. 2
      src/fiat/dion
  79. 2
      src/fiat/dsec
  80. 2
      src/fiat/eql
  81. 2
      src/fiat/etomic
  82. 2
      src/fiat/glxt
  83. 2
      src/fiat/hodl
  84. 3
      src/fiat/ilien
  85. 2
      src/fiat/iln
  86. 2
      src/fiat/jumblr
  87. 2
      src/fiat/k64
  88. 2
      src/fiat/kmdice
  89. 2
      src/fiat/koin
  90. 2
      src/fiat/ksb
  91. 2
      src/fiat/kv
  92. 2
      src/fiat/mesh
  93. 2
      src/fiat/mgnx
  94. 2
      src/fiat/mgw
  95. 2
      src/fiat/mnz
  96. 2
      src/fiat/morty
  97. 2
      src/fiat/mshark
  98. 2
      src/fiat/ninja
  99. 2
      src/fiat/oot
  100. 2
      src/fiat/our
  101. 2
      src/fiat/pangea
  102. 2
      src/fiat/pgt
  103. 2
      src/fiat/pirate
  104. 2
      src/fiat/pizza
  105. 2
      src/fiat/prlpay
  106. 2
      src/fiat/revs
  107. 2
      src/fiat/rfox
  108. 2
      src/fiat/rick
  109. 2
      src/fiat/sec
  110. 2
      src/fiat/supernet
  111. 2
      src/fiat/thc
  112. 2
      src/fiat/wlc
  113. 2
      src/fiat/zexo
  114. 2
      src/fiat/zilla
  115. 27
      src/gui/komodoku/README.md
  116. BIN
      src/gui/komodoku/Roboto-Light.ttf
  117. 362
      src/gui/komodoku/Sudoku.py
  118. BIN
      src/gui/komodoku/background.png
  119. BIN
      src/gui/komodoku/board.png
  120. 41
      src/gui/komodoku/sudoku_kmdlib.py
  121. 27
      src/komodo.h
  122. 16
      src/komodo_ccdata.h
  123. 4
      src/komodo_defs.h
  124. 24
      src/komodo_gateway.h
  125. 795
      src/komodo_jumblr.h
  126. 8
      src/komodo_kv.h
  127. 160
      src/komodo_nSPV.h
  128. 54
      src/komodo_nSPV_fullnode.h
  129. 50
      src/komodo_nSPV_superlite.h
  130. 18
      src/komodo_pax.h
  131. 14
      src/komodo_port.c
  132. 60
      src/komodo_utils.h
  133. 4
      src/notaries_staked.h
  134. 98
      src/notarystats.py
  135. 77
      src/rpc/misc.cpp
  136. 16
      src/rpc/server.cpp
  137. 7
      src/rpc/server.h
  138. 4
      src/sc/hush
  139. 3
      src/sc/koolaid
  140. 3
      src/sc/kush
  141. 3
      src/sc/zex
  142. 7
      src/smartchains
  143. 22
      src/smartchains.json
  144. 17
      src/smartchains.old
  145. 21
      src/tui/LICENSE
  146. 58
      src/tui/README.md
  147. 39
      src/tui/lib/logo.txt
  148. 129
      src/tui/lib/rpclib.py
  149. 1992
      src/tui/lib/tuilib.py
  150. 8
      src/tui/requirements.txt
  151. 67
      src/tui/tui_assets.py
  152. 67
      src/tui/tui_gateways_creation.py
  153. 96
      src/tui/tui_gateways_usage.py
  154. 68
      src/tui/tui_marmara.py
  155. 67
      src/tui/tui_oracles.py
  156. 116
      src/tui/tui_rogue.py
  157. 96
      src/tui/tui_tetris.py
  158. 16
      src/wallet/rpcwallet.cpp
  159. 11
      src/zcash/JoinSplit.cpp
  160. 13
      src/zcash/JoinSplit.hpp

2
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

72
makeReleaseMac.sh

@ -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

12
resolve.sh

@ -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

2
src/ac/axo

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=AXO $1 $2 $3 $4 $5 $6

2
src/ac/beer

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=BEER $1 $2 $3 $4 $5 $6

2
src/ac/bet

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=BET $1 $2 $3 $4 $5 $6

2
src/ac/bntn

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=BNTN $1 $2 $3 $4 $5 $6

2
src/ac/bots

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=BOTS $1 $2 $3 $4 $5 $6

2
src/ac/btch

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=BTCH $1 $2 $3 $4 $5 $6

2
src/ac/ccl

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=CCL $1 $2 $3 $4 $5 $6

2
src/ac/ceal

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=CEAL $1 $2 $3 $4 $5 $6

2
src/ac/chain

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=CHAIN $1 $2 $3 $4 $5 $6

2
src/ac/coquicash

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=COQUICASH $1 $2 $3 $4 $5 $6

2
src/ac/crypto

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=CRYPTO $1 $2 $3 $4 $5 $6

2
src/ac/dex

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=DEX $1 $2 $3 $4 $5 $6

2
src/ac/dion

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=DION $1 $2 $3 $4 $5 $6

2
src/ac/dsec

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=DSEC $1 $2 $3 $4 $5 $6

2
src/ac/eql

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=EQL $1 $2 $3 $4 $5 $6

2
src/ac/etomic

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=ETOMIC $1 $2 $3 $4 $5 $6

2
src/ac/glxt

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=GLXT $1 $2 $3 $4 $5 $6

2
src/ac/hodl

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=HODL $1 $2 $3 $4 $5 $6

3
src/ac/ilien

@ -1,3 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=ILN $1 $2 $3 $4 $5 $6

2
src/ac/iln

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=ILN $1 $2 $3 $4 $5 $6

2
src/ac/jumblr

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=JUMBLR $1 $2 $3 $4 $5 $6

2
src/ac/k64

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=K64 $1 $2 $3 $4 $5 $6

2
src/ac/kmdice

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=KMDICE $1 $2 $3 $4 $5 $6

2
src/ac/koin

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=KOIN $1 $2 $3 $4 $5 $6

2
src/ac/ksb

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=KSB $1 $2 $3 $4 $5 $6

2
src/ac/kv

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=KV $1 $2 $3 $4 $5 $6

2
src/ac/mesh

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=MESH $1 $2 $3 $4 $5 $6

2
src/ac/mgnx

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=MGNX $1 $2 $3 $4 $5 $6

2
src/ac/mgw

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=MGW $1 $2 $3 $4 $5 $6

2
src/ac/mnz

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=MNZ $1 $2 $3 $4 $5 $6

2
src/ac/morty

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=MORTY $1 $2 $3 $4 $5 $6

2
src/ac/mshark

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=MSHARK $1 $2 $3 $4 $5 $6

2
src/ac/ninja

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=NINJA $1 $2 $3 $4 $5 $6

2
src/ac/oot

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=OOT $1 $2 $3 $4 $5 $6

2
src/ac/our

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=OUR $1 $2 $3 $4 $5 $6

2
src/ac/pangea

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=PANGEA $1 $2 $3 $4 $5 $6

2
src/ac/pgt

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=PGT $1 $2 $3 $4 $5 $6

2
src/ac/pirate

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=PIRATE $1 $2 $3 $4 $5 $6

2
src/ac/pizza

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=PIZZA $1 $2 $3 $4 $5 $6

2
src/ac/prlpay

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=PRLPAY $1 $2 $3 $4 $5 $6

2
src/ac/revs

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=REVS $1 $2 $3 $4 $5 $6

2
src/ac/rick

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=RICK $1 $2 $3 $4 $5 $6

2
src/ac/supernet

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=SUPERNET $1 $2 $3 $4 $5 $6

2
src/ac/thc

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=THC $1 $2 $3 $4 $5 $6

2
src/ac/vote2018

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=VOTE2018 $1 $2 $3 $4 $5 $6

2
src/ac/vote2019

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=VOTE2019 $1 $2 $3 $4 $5 $6

2
src/ac/wlc

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=WLC $1 $2 $3 $4 $5 $6

2
src/ac/zexo

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=ZEXO $1 $2 $3 $4 $5 $6

337
src/assetchains.json

@ -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"
]
}
]

55
src/assetchains.old

@ -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 &

4
src/cc/CCinclude.h

@ -309,8 +309,8 @@ int32_t myGet_mempool_txs(std::vector<CTransaction> &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<CPubKey>& keys);

44
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;
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);
struct dragon_msghdr { uint8_t netmagic[4]; char command[12]; uint8_t serdatalen[4],hash[4]; } PACKED;
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);

17
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

52
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.
### 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
./oraclefeed $ACNAME $ORACLETXID $MYPUBKEY $FORMAT $BINDTXID [refcoin_cli]
* 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.

9
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 )

370
src/cc/dapps/subatomic.c → 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; i<numseconds; i++)
{
if ( coin->isfile != 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 <locktime> CLTV OP_DROP <pubkeyA> 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);

19
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" }
]
}

1151
src/cc/dapps/oraclefeed.c

File diff suppressed because it is too large

27
src/cc/dapps/subatomic.json

@ -1,27 +0,0 @@
{
"authorized": [
{"chmex":"030754bffcf6dfcb34a20c486ff5a5be5546b9cc16fba9692165272b3f8e98c4af" },
{"SHossain":"03c8657bd57b6ceb14514a10e99fe8a0cec5a9bc24592df7f66f050e670e4f6bac" },
{"satinder":"03732f8ef851ff234c74d0df575c2c5b159e2bab3faca4ec52b3f217d5cda5361d" },
{"ml777":"02453d028c74cb9551e1aaf35113383b6ecbd9f06ff23a4ab1a953429b9763e345" },
{"tonylhub":"0218e0f435d4544404c25a7759b7f7174d821215085ef936218c5569d975af468b" },
{"gthub":"036c7de9a5090fbad78b9eea41549ccacc07bd0e9e7f8d290c88f470f3569e1a35" },
{"zkTrader":"026c6b0b35ec0adc2f8a5c648da1fce634f798c69d5e9fe518400447e88398b830" },
{"nutellalicka":"03aee08860e0340f0f490a3ef3718d6676882f2d63d4f536dfebb1d348b82c79ee" },
{"gcharang":"02d3431950c2f0f9654217b6ce3d44468d3a9ca7255741767fdeee7c5ec6b47567" },
{"jl777":"02b27de3ee5335518b06f69f4fbabb029cfc737613b100996841d5532b324a5a61" }
],
"tokens":[
{"RICK.demo":"2b1feef719ecb526b07416dd432bce603ac6dc8bfe794cddf105cb52f6aae3cd"}
],
"files":[
{"filename":"hushd","prices":[{"HUSH":0.1}, {"PIRATE":1}]}
],
"externalcoins":[
{ "BTC":"bitcoin-cli" },
{ "KMD":"komodod-cli" },
{ "CHIPS":"chips-cli" },
{ "PIRATE":"pirate-cli" }
]
}

4
src/cc/includes/curve25519.h

@ -55,8 +55,8 @@ void vcalc_sha256(char hashstr[(256 >> 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);

14
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);

9
src/fiat-cli

@ -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

2
src/fiat/axo

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=AXO $1 $2 $3 $4 $5 $6

2
src/fiat/beer

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=BEER $1 $2 $3 $4 $5 $6

2
src/fiat/bet

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=BET $1 $2 $3 $4 $5 $6

2
src/fiat/bntn

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=BNTN $1 $2 $3 $4 $5 $6

2
src/fiat/bots

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=BOTS $1 $2 $3 $4 $5 $6

2
src/fiat/btch

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=BTCH $1 $2 $3 $4 $5 $6

2
src/fiat/ccl

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=CCL $1 $2 $3 $4 $5 $6

2
src/fiat/ceal

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=CEAL $1 $2 $3 $4 $5 $6

2
src/fiat/chain

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=CHAIN $1 $2 $3 $4 $5 $6

2
src/fiat/coquicash

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=COQUICASH $1 $2 $3 $4 $5 $6

2
src/fiat/crypto

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=CRYPTO $1 $2 $3 $4 $5 $6

2
src/fiat/dex

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=DEX $1 $2 $3 $4 $5 $6

2
src/fiat/dion

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=DION $1 $2 $3 $4 $5 $6

2
src/fiat/dsec

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=DSEC $1 $2 $3 $4 $5 $6

2
src/fiat/eql

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=EQL $1 $2 $3 $4 $5 $6

2
src/fiat/etomic

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=ETOMIC $1 $2 $3 $4 $5 $6

2
src/fiat/glxt

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=GLXT $1 $2 $3 $4 $5 $6

2
src/fiat/hodl

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=HODL $1 $2 $3 $4 $5 $6

3
src/fiat/ilien

@ -1,3 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=ILN $1 $2 $3 $4 $5 $6

2
src/fiat/iln

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=ILN $1 $2 $3 $4 $5 $6

2
src/fiat/jumblr

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=JUMBLR $1 $2 $3 $4 $5 $6

2
src/fiat/k64

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=K64 $1 $2 $3 $4 $5 $6

2
src/fiat/kmdice

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=KMDICE $1 $2 $3 $4 $5 $6

2
src/fiat/koin

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=KOIN $1 $2 $3 $4 $5 $6

2
src/fiat/ksb

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=KSB $1 $2 $3 $4 $5 $6

2
src/fiat/kv

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=KV $1 $2 $3 $4 $5 $6

2
src/fiat/mesh

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=MESH $1 $2 $3 $4 $5 $6

2
src/fiat/mgnx

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=MGNX $1 $2 $3 $4 $5 $6

2
src/fiat/mgw

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=MGW $1 $2 $3 $4 $5 $6

2
src/fiat/mnz

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=MNZ $1 $2 $3 $4 $5 $6

2
src/fiat/morty

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=MORTY $1 $2 $3 $4 $5 $6

2
src/fiat/mshark

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=MSHARK $1 $2 $3 $4 $5 $6

2
src/fiat/ninja

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=NINJA $1 $2 $3 $4 $5 $6

2
src/fiat/oot

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=OOT $1 $2 $3 $4 $5 $6

2
src/fiat/our

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=OUR $1 $2 $3 $4 $5 $6

2
src/fiat/pangea

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=PANGEA $1 $2 $3 $4 $5 $6

2
src/fiat/pgt

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=PGT $1 $2 $3 $4 $5 $6

2
src/fiat/pirate

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=PIRATE $1 $2 $3 $4 $5 $6

2
src/fiat/pizza

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=PIZZA $1 $2 $3 $4 $5 $6

2
src/fiat/prlpay

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=PRLPAY $1 $2 $3 $4 $5 $6

2
src/fiat/revs

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=REVS $1 $2 $3 $4 $5 $6

2
src/fiat/rfox

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=RFOX $1 $2 $3 $4 $5 $6

2
src/fiat/rick

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=RICK $1 $2 $3 $4 $5 $6

2
src/fiat/sec

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=SEC $1 $2 $3 $4 $5 $6

2
src/fiat/supernet

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=SUPERNET $1 $2 $3 $4 $5 $6

2
src/fiat/thc

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=THC $1 $2 $3 $4 $5 $6

2
src/fiat/wlc

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=WLC $1 $2 $3 $4 $5 $6

2
src/fiat/zexo

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=ZEXO $1 $2 $3 $4 $5 $6

2
src/fiat/zilla

@ -1,2 +0,0 @@
#!/bin/bash
./komodo-cli -ac_name=ZILLA $1 $2 $3 $4 $5 $6

27
src/gui/komodoku/README.md

@ -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=<yourpubkey> -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
```

BIN
src/gui/komodoku/Roboto-Light.ttf

Binary file not shown.

362
src/gui/komodoku/Sudoku.py

@ -1,362 +0,0 @@
#!/usr/bin/env python
# Copyright (C) 2010 Paul Bourke <pauldbourke@gmail.com>
# Copyright (C) 2019 Anton Lysakov <tlysakov@gmail.com>
#
# 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 <http://www.gnu.org/licenses/>.
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<txid>%22,%22<solution>%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()

BIN
src/gui/komodoku/background.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 301 KiB

BIN
src/gui/komodoku/board.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.5 KiB

41
src/gui/komodoku/sudoku_kmdlib.py

@ -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))))

27
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; k<MoMoMdata.numpairs; k++)
{
len += iguana_rwnum(0,&scriptbuf[len],sizeof(int32_t),(uint8_t *)&MoMoMdata.pairs[k].notarized_height);
len += iguana_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.pairs[k].MoMoMoffset);
len += dragon_rwnum(0,&scriptbuf[len],sizeof(int32_t),(uint8_t *)&MoMoMdata.pairs[k].notarized_height);
len += dragon_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.pairs[k].MoMoMoffset);
MoMoMdata.len += sizeof(uint32_t) * 2;
}
} else ccdata.len = MoMoMdata.len = 0;

16
src/komodo_ccdata.h

@ -147,12 +147,12 @@ int32_t komodo_MoMoMdata(char *hexstr,int32_t hexsize,struct komodo_ccdataMoMoM
}
if ( mdata->numpairs > 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; i<mdata->numpairs; 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 )
{

4
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" },

24
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;

795
src/komodo_jumblr.h

@ -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":"<hex>"},...] ( minconf ) ( fee )
*/
#ifdef _WIN32
#include <wincrypt.h>
#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<Jumblr_numsecretaddrs; i++)
{
if ( strcmp(searchaddr,Jumblr_secretaddrs[i]) == 0 )
return(i);
}
return(-1);
}
int32_t Jumblr_secretaddradd(char *secretaddr) // external
{
int32_t ind;
if ( secretaddr != 0 && secretaddr[0] != 0 )
{
if ( Jumblr_numsecretaddrs < JUMBLR_MAXSECRETADDRS )
{
if ( strcmp(Jumblr_deposit,secretaddr) != 0 )
{
if ( (ind= Jumblr_secretaddrfind(secretaddr)) < 0 )
{
ind = Jumblr_numsecretaddrs++;
safecopy(Jumblr_secretaddrs[ind],secretaddr,64);
}
return(ind);
} else return(JUMBLR_ERROR_SECRETCANTBEDEPOSIT);
} else return(JUMBLR_ERROR_TOOMANYSECRETS);
}
else
{
memset(Jumblr_secretaddrs,0,sizeof(Jumblr_secretaddrs));
Jumblr_numsecretaddrs = 0;
}
return(Jumblr_numsecretaddrs);
}
int32_t Jumblr_depositaddradd(char *depositaddr) // external
{
int32_t ind,retval = JUMBLR_ERROR_DUPLICATEDEPOSIT; char *retstr; cJSON *retjson,*ismine;
if ( depositaddr == 0 )
depositaddr = (char *)"";
if ( (ind= Jumblr_secretaddrfind(depositaddr)) < 0 )
{
if ( (retstr= jumblr_validateaddress(depositaddr)) != 0 )
{
if ( (retjson= cJSON_Parse(retstr)) != 0 )
{
if ( (ismine= jobj(retjson,(char *)"ismine")) != 0 && cJSON_IsTrue(ismine) != 0 )
{
retval = 0;
safecopy(Jumblr_deposit,depositaddr,sizeof(Jumblr_deposit));
}
else
{
retval = JUMBLR_ERROR_NOTINWALLET;
printf("%s not in wallet: ismine.%p %d %s\n",depositaddr,ismine,cJSON_IsTrue(ismine),jprint(retjson,0));
}
free_json(retjson);
}
free(retstr);
}
}
return(retval);
}
#ifdef _WIN32
void OS_randombytes(unsigned char *x,long xlen)
{
HCRYPTPROV prov = 0;
CryptAcquireContextW(&prov, NULL, NULL,PROV_RSA_FULL, CRYPT_VERIFYCONTEXT | CRYPT_SILENT);
CryptGenRandom(prov, xlen, x);
CryptReleaseContext(prov, 0);
}
#endif
int32_t Jumblr_secretaddr(char *secretaddr)
{
uint32_t r;
if ( Jumblr_numsecretaddrs > 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<n; i++)
balance += SATOSHIDEN * jdouble(jitem(retjson,i),(char *)"amount");
free_json(retjson);
}
free(retstr);
}
}
else*/ if ( (retstr= jumblr_zgetbalance(addr)) != 0 )
{
if ( (val= atof(retstr)) > 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<n; i++)
{
dest = jitem(amounts,i);
//printf("%s ",jprint(dest,0));
if ( (addr= jstr(dest,(char *)"address")) != 0 && (amount= jdouble(dest,(char *)"amount")*SATOSHIDEN) > 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; i<n; i++)
{
if ( (ptr= jumblr_opidadd(jstri(array,i))) != 0 )
{
if ( ptr->status == 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<n; i++)
printf("%.8f ",dstr(incrs[i]));
printf("n.%d incrs r.%d -> %.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; i<n; i++)
jumblr_zaddrinit(jstri(array,i));
}
free_json(array);
}
free(retstr), retstr = 0;
}
}
height = (int32_t)chainActive.LastTip()->GetHeight();
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;
}
}

8
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 )
{

160
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; i<ptr->numutxos; 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; i<ptr->numtxids; 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; i<ptr->numtxids; 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<uint8_t> 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++)

54
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; i<ptr->numtxids; 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<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> 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<uint8_t> 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));

50
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)
{

18
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];

14
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));
}

60
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<Mineropret.size(); i++)
@ -2254,7 +2254,7 @@ fprintf(stderr,"extralen.%d before disable bits\n",extralen);
}
if ( ASSETCHAINS_CBOPRET != 0 )
{
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_CBOPRET),(void *)&ASSETCHAINS_CBOPRET);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_CBOPRET),(void *)&ASSETCHAINS_CBOPRET);
if ( ASSETCHAINS_PRICES.size() != 0 )
{
for (i=0; i<ASSETCHAINS_PRICES.size(); i++)
@ -2279,20 +2279,20 @@ fprintf(stderr,"extralen.%d before disable bits\n",extralen);
}
if ( ASSETCHAINS_NK[0] != 0 && ASSETCHAINS_NK[1] != 0 )
{
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NK[0]),(void *)&ASSETCHAINS_NK[0]);
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NK[1]),(void *)&ASSETCHAINS_NK[1]);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NK[0]),(void *)&ASSETCHAINS_NK[0]);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NK[1]),(void *)&ASSETCHAINS_NK[1]);
}
if ( KOMODO_SNAPSHOT_INTERVAL != 0 )
{
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(KOMODO_SNAPSHOT_INTERVAL),(void *)&KOMODO_SNAPSHOT_INTERVAL);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(KOMODO_SNAPSHOT_INTERVAL),(void *)&KOMODO_SNAPSHOT_INTERVAL);
}
if ( ASSETCHAINS_EARLYTXIDCONTRACT != 0 )
{
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_EARLYTXIDCONTRACT),(void *)&ASSETCHAINS_EARLYTXIDCONTRACT);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_EARLYTXIDCONTRACT),(void *)&ASSETCHAINS_EARLYTXIDCONTRACT);
}
if ( ASSETCHAINS_CBMATURITY != 0 )
{
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_CBMATURITY),(void *)&ASSETCHAINS_CBMATURITY);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_CBMATURITY),(void *)&ASSETCHAINS_CBMATURITY);
}
if ( ASSETCHAINS_ADAPTIVEPOW != 0 )
extraptr[extralen++] = ASSETCHAINS_ADAPTIVEPOW;
@ -2363,7 +2363,7 @@ fprintf(stderr,"extralen.%d before disable bits\n",extralen);
ASSETCHAINS_RPCPORT = ASSETCHAINS_P2PPORT + 1;
//ASSETCHAINS_NOTARIES = GetArg("-ac_notaries","");
//komodo_assetchain_pubkeys((char *)ASSETCHAINS_NOTARIES.c_str());
iguana_rwnum(1,magic,sizeof(ASSETCHAINS_MAGIC),(void *)&ASSETCHAINS_MAGIC);
dragon_rwnum(1,magic,sizeof(ASSETCHAINS_MAGIC),(void *)&ASSETCHAINS_MAGIC);
for (i=0; i<4; i++)
sprintf(&magicstr[i<<1],"%02x",magic[i]);
magicstr[8] = 0;
@ -2374,7 +2374,7 @@ fprintf(stderr,"extralen.%d before disable bits\n",extralen);
int8_t notarypay = 0;
if ( ASSETCHAINS_NOTARY_PAY[0] != 0 )
notarypay = 1;
fprintf(fp,iguanafmtstr,name.c_str(),name.c_str(),name.c_str(),name.c_str(),magicstr,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,"78.47.196.146",notarypay);
fprintf(fp,dragonfmtstr,name.c_str(),name.c_str(),name.c_str(),name.c_str(),magicstr,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,"78.47.196.146",notarypay);
fclose(fp);
//printf("created (%s)\n",fname);
} else printf("error creating (%s)\n",fname);

4
src/notaries_staked.h

@ -5,10 +5,10 @@
#include "crosschain.h"
#include "cc/CCinclude.h"
static const int32_t iguanaPort = 9333;
static const int32_t dragonPort = 9333;
static const int8_t BTCminsigs = 13;
static const int8_t overrideMinSigs = 7;
static const char *iguanaSeeds[8][1] =
static const char *dragonSeeds[8][1] =
{
{"94.23.1.95"},
{"103.6.12.112"},

98
src/notarystats.py

@ -1,98 +0,0 @@
#!/usr/bin/env python3
"""
sudo apt-get install python3-dev
sudo apt-get install python3 libgnutls28-dev libssl-dev
sudo apt-get install python3-pip
pip3 install setuptools
pip3 install wheel
pip3 install base58 slick-bitcoinrpc
./notarystats.py
------------------------------------------------
"""
import platform
import os
import re
import sys
import time
import pprint
from slickrpc import Proxy
# fucntion to define rpc_connection
def def_credentials(chain):
rpcport = '';
operating_system = platform.system()
if operating_system == 'Darwin':
ac_dir = os.environ['HOME'] + '/Library/Application Support/Komodo'
elif operating_system == 'Linux':
ac_dir = os.environ['HOME'] + '/.komodo'
elif operating_system == 'Windows':
ac_dir = '%s/komodo/' % os.environ['APPDATA']
if chain == 'KMD':
coin_config_file = str(ac_dir + '/komodo.conf')
else:
coin_config_file = str(ac_dir + '/' + chain + '/' + chain + '.conf')
with open(coin_config_file, 'r') as f:
for line in f:
l = line.rstrip()
if re.search('rpcuser', l):
rpcuser = l.replace('rpcuser=', '')
elif re.search('rpcpassword', l):
rpcpassword = l.replace('rpcpassword=', '')
elif re.search('rpcport', l):
rpcport = l.replace('rpcport=', '')
if len(rpcport) == 0:
if chain == 'KMD':
rpcport = 7771
else:
print("rpcport not in conf file, exiting")
print("check " + coin_config_file)
exit(1)
return (Proxy("http://%s:%s@127.0.0.1:%d" % (rpcuser, rpcpassword, int(rpcport))))
rpc = def_credentials('KMD')
pp = pprint.PrettyPrinter(indent=2)
notarynames = [ "0dev1_jl777", "0dev2_kolo", "0dev3_kolo", "0dev4_decker_AR", "a-team_SH", "artik_AR", "artik_EU", "artik_NA", "artik_SH", "badass_EU", "badass_NA", "batman_AR", "batman_SH", "ca333", "chainmakers_EU", "chainmakers_NA", "chainstrike_SH", "cipi_AR", "cipi_NA", "crackers_EU", "crackers_NA", "dwy_EU", "emmanux_SH", "etszombi_EU", "fullmoon_AR", "fullmoon_NA", "fullmoon_SH", "goldenman_EU", "indenodes_AR", "indenodes_EU", "indenodes_NA", "indenodes_SH", "jackson_AR", "jeezy_EU", "karasugoi_NA", "komodoninja_EU", "komodoninja_SH", "komodopioneers_SH", "libscott_SH", "lukechilds_AR", "madmax_AR", "meshbits_AR", "meshbits_SH", "metaphilibert_AR", "metaphilibert_SH", "patchkez_SH", "pbca26_NA", "peer2cloud_AR", "peer2cloud_SH", "polycryptoblog_NA", "hyper_AR", "hyper_EU", "hyper_SH", "hyper_NA", "popcornbag_AR", "popcornbag_NA", "alien_AR", "alien_EU", "thegaltmines_NA", "titomane_AR", "titomane_EU", "titomane_SH", "webworker01_NA", "xrobesx_NA" ]
notaries = 64 * [0]
startheight = 821657 #Second time filter for assetchains (block 821657) for KMD its 814000
stopheight = 1307200
for i in range(startheight,stopheight):
ret = rpc.getNotarisationsForBlock(i)
KMD = ret['KMD']
if len(KMD) > 0:
for obj in KMD:
#for now skip KMD for this. As official stats are from BTC chain
# 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)

77
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)

16
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

7
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);

4
src/fiat/hush → 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 $@

3
src/sc/koolaid

@ -0,0 +1,3 @@
#!/bin/bash
# Copyright (c) 2018-2020 The Hush developers
./hush-smart-chain -ac_name=KOOLAID $@

3
src/sc/kush

@ -0,0 +1,3 @@
#!/bin/bash
# Copyright (c) 2018-2020 The Hush developers
./hush-smart-chain -ac_name=KUSH $@

3
src/sc/zex

@ -0,0 +1,3 @@
#!/bin/bash
# Copyright (c) 2018-2020 The Hush developers
./hush-smart-chain -ac_name=ZEX $@

7
src/assetchains → 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

22
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"
]
}
]

17
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 $@ &

21
src/tui/LICENSE

@ -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.

58
src/tui/README.md

@ -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.

39
src/tui/lib/logo.txt

@ -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

129
src/tui/lib/rpclib.py

@ -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

1992
src/tui/lib/tuilib.py

File diff suppressed because it is too large

8
src/tui/requirements.txt

@ -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

67
src/tui/tui_assets.py

@ -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()

67
src/tui/tui_gateways_creation.py

@ -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()

96
src/tui/tui_gateways_usage.py

@ -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()

68
src/tui/tui_marmara.py

@ -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()

67
src/tui/tui_oracles.py

@ -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()

116
src/tui/tui_rogue.py

@ -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()

96
src/tui/tui_tetris.py

@ -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()

16
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"

11
src/zcash/JoinSplit.cpp

@ -5,21 +5,10 @@
#include "prf.h"
#include "sodium.h"
#include "zcash/util.h"
#include <memory>
#include <boost/foreach.hpp>
#include <boost/format.hpp>
#include <boost/optional.hpp>
#include <fstream>
#include "tinyformat.h"
#include "sync.h"
#include "amount.h"
#include "librustzcash.h"
#include "streams.h"
#include "version.h"
namespace libzcash {

13
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<unsigned char, GROTH_PROOF_SIZE> GrothProof;
typedef boost::variant<PHGRProof, GrothProof> SproutProof;
class JSInput {
};
class JSInput { };
class JSOutput {
};
class JSOutput { };
template<size_t NumInputs, size_t NumOutputs>
class JoinSplit {
};
class JoinSplit { };
}
typedef libzcash::JoinSplit<ZC_NUM_JS_INPUTS,
ZC_NUM_JS_OUTPUTS> ZCJoinSplit;
typedef libzcash::JoinSplit<ZC_NUM_JS_INPUTS, ZC_NUM_JS_OUTPUTS> ZCJoinSplit;
#endif // ZC_JOINSPLIT_H_

Loading…
Cancel
Save