Merge upstream FSM into duke

This commit is contained in:
Duke Leto
2019-10-09 22:00:02 -04:00
57 changed files with 906 additions and 635 deletions

View File

@@ -6,9 +6,6 @@ matrix:
dist: xenial dist: xenial
sudo: required sudo: required
env: LINUX_DEPLOY="true" OSX_DEPLOY="false" $TRAVIS_OS_NAME="linux" env: LINUX_DEPLOY="true" OSX_DEPLOY="false" $TRAVIS_OS_NAME="linux"
- os: osx
osx_image: xcode8
env: OSX_DEPLOY="true" LINUX_DEPLOY="false" $TRAVIS_OS_NAME="osx"
branches: branches:
only: only:
- master - master

View File

@@ -56,7 +56,7 @@ def sync_blocks(rpc_connections, wait=1):
def sync_mempools(rpc_connections, wait=1): def sync_mempools(rpc_connections, wait=1):
""" """
Wait until everybody has the same transactions in their memory Wait until everybody has the same transactions in their memory
pools pools, and has notified all internal listeners of them
""" """
while True: while True:
pool = set(rpc_connections[0].getrawmempool()) pool = set(rpc_connections[0].getrawmempool())
@@ -68,6 +68,14 @@ def sync_mempools(rpc_connections, wait=1):
break break
time.sleep(wait) time.sleep(wait)
# Now that the mempools are in sync, wait for the internal
# notifications to finish
while True:
notified = [ x.getmempoolinfo()['fullyNotified'] for x in rpc_connections ]
if notified == [ True ] * len(notified):
break
time.sleep(wait)
bitcoind_processes = {} bitcoind_processes = {}
def initialize_datadir(dirname, n): def initialize_datadir(dirname, n):

View File

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

2
src/ac/coquicash Executable file
View File

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

2
src/ac/thc Executable file
View File

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

View File

@@ -5,6 +5,7 @@ set -eo pipefail
source pubkey.txt source pubkey.txt
overide_args="$@" overide_args="$@"
seed_ip=`getent hosts zero.kolo.supernet.org | awk '{ print $1 }'` seed_ip=`getent hosts zero.kolo.supernet.org | awk '{ print $1 }'`
komodo_binary='./komodod'
if [ -z "$delay" ]; then delay=20; fi if [ -z "$delay" ]; then delay=20; fi
@@ -14,6 +15,6 @@ if [ -z "$delay" ]; then delay=20; fi
gen=" -gen -genproclimit=1" gen=" -gen -genproclimit=1"
fi fi
./komodod $gen $args $overide_args -pubkey=$pubkey -addnode=$seed_ip & $komodo_binary $gen $args $overide_args -pubkey=$pubkey -addnode=$seed_ip &
sleep $delay sleep $delay
done done

View File

@@ -84,14 +84,6 @@
"ac_name": "BTCH", "ac_name": "BTCH",
"ac_supply": "20998641" "ac_supply": "20998641"
}, },
{
"ac_name": "PIZZA",
"ac_supply": "100000000"
},
{
"ac_name": "BEER",
"ac_supply": "100000000"
},
{ {
"ac_name": "NINJA", "ac_name": "NINJA",
"ac_supply": "100000000" "ac_supply": "100000000"
@@ -117,10 +109,6 @@
"ac_name": "DSEC", "ac_name": "DSEC",
"ac_supply": "7000000" "ac_supply": "7000000"
}, },
{
"ac_name": "GLXT",
"ac_supply": "10000000000"
},
{ {
"ac_name": "EQL", "ac_name": "EQL",
"ac_supply": "500000000", "ac_supply": "500000000",
@@ -233,14 +221,22 @@
"ac_supply": "90000000000", "ac_supply": "90000000000",
"ac_reward": "100000000", "ac_reward": "100000000",
"ac_cc": "3", "ac_cc": "3",
"addnode": ["138.201.136.145"] "ac_staked": "10",
"addnode": [
"138.201.136.145",
"95.217.44.58"
]
}, },
{ {
"ac_name": "MORTY", "ac_name": "MORTY",
"ac_supply": "90000000000", "ac_supply": "90000000000",
"ac_reward": "100000000", "ac_reward": "100000000",
"ac_cc": "3", "ac_cc": "3",
"addnode": ["138.201.136.145"] "ac_staked": "10",
"addnode": [
"138.201.136.145",
"95.217.44.58"
]
}, },
{ {
"ac_name": "KOIN", "ac_name": "KOIN",
@@ -291,5 +287,25 @@
"136.243.227.142", "136.243.227.142",
"5.9.224.250" "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"
]
} }
] ]

View File

@@ -15,7 +15,7 @@ echo $pubkey
./komodod -pubkey=$pubkey -ac_name=MSHARK -ac_supply=1400000 -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=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=MGW -ac_supply=999999 -addnode=95.213.238.98 $1 &
./komodod -pubkey=$pubkey -ac_name=COQUI -ac_supply=72000000 -ac_ccactivate=200000 -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=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=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=CEAL -ac_supply=366666666 -addnode=95.213.238.98 $1 &
@@ -23,15 +23,15 @@ echo $pubkey
./komodod -pubkey=$pubkey -ac_name=AXO -ac_supply=200000000 -ac_ccactivate=130000 -addnode=95.213.238.98 & ./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=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=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=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=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=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=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=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=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=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=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=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=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=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=RFOX -ac_supply=1000000000 -ac_reward=100000000 -addnode=95.213.238.98 &
@@ -46,10 +46,14 @@ echo $pubkey
./komodod -pubkey=$pubkey -ac_name=KSB -ac_supply=1000000000 -ac_end=1 -ac_public=1 -addnode=37.187.225.231 & ./komodod -pubkey=$pubkey -ac_name=KSB -ac_supply=1000000000 -ac_end=1 -ac_public=1 -addnode=37.187.225.231 &
./komodod -pubkey=$pubkey -ac_name=OUR -ac_reward=1478310502 -ac_halving=525600 -ac_cc=42 -ac_supply=100000000 -ac_perc=77700 -ac_staked=93 -ac_pubkey=02652a3f3e00b3a1875a918314f0bac838d6dd189a346fa623f5efe9541ac0b98c -ac_public=1 -addnode=51.255.195.65 -addnode=217.182.129.38 -addnode=37.187.225.231 & ./komodod -pubkey=$pubkey -ac_name=OUR -ac_reward=1478310502 -ac_halving=525600 -ac_cc=42 -ac_supply=100000000 -ac_perc=77700 -ac_staked=93 -ac_pubkey=02652a3f3e00b3a1875a918314f0bac838d6dd189a346fa623f5efe9541ac0b98c -ac_public=1 -addnode=51.255.195.65 -addnode=217.182.129.38 -addnode=37.187.225.231 &
./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=ILN -ac_supply=10000000000 -ac_cc=2 -addressindex=1 -spentindex=1 -addnode=51.75.122.83 &
./komodod -pubkey=$pubkey -ac_name=RICK -ac_supply=90000000000 -ac_reward=100000000 -ac_cc=3 -addnode=138.201.136.145 & ./komodod -pubkey=$pubkey -ac_name=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 -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 &
<<<<<<< HEAD
./komodod -pubkey=$pubkey -ac_name=VOTE2019 -ac_supply=123651638 -ac_public=1 -addnode=95.213.238.98 & ./komodod -pubkey=$pubkey -ac_name=VOTE2019 -ac_supply=123651638 -ac_public=1 -addnode=95.213.238.98 &
=======
>>>>>>> beta
./komodod -pubkey=$pubkey -ac_name=KOIN -ac_supply=125000000 -addnode=3.0.32.10 & ./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=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=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=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 &

View File

@@ -1,6 +1,8 @@
#!/bin/bash #!/bin/bash
set -eo pipefail set -eo pipefail
komodo_cli='./komodo-cli'
./listassetchains | while read chain; do ./listassetchains | while read chain; do
./komodo-cli --ac_name=$chain stop $komodo_cli --ac_name=$chain stop
done done

View File

@@ -76,14 +76,14 @@ void WaitForShutdown(boost::thread_group* threadGroup)
fprintf(stderr,"error: earlytx must be before block height %d or tx does not exist\n",KOMODO_EARLYTXID_HEIGHT); fprintf(stderr,"error: earlytx must be before block height %d or tx does not exist\n",KOMODO_EARLYTXID_HEIGHT);
StartShutdown(); StartShutdown();
} }
if ( ASSETCHAINS_STAKED == 0 && ASSETCHAINS_ADAPTIVEPOW == 0 && (pindex= komodo_chainactive(1)) != 0 ) /*if ( ASSETCHAINS_STAKED == 0 && ASSETCHAINS_ADAPTIVEPOW == 0 && (pindex= komodo_chainactive(1)) != 0 )
{ {
if ( pindex->nTime > ADAPTIVEPOW_CHANGETO_DEFAULTON ) if ( pindex->nTime > ADAPTIVEPOW_CHANGETO_DEFAULTON )
{ {
ASSETCHAINS_ADAPTIVEPOW = 1; ASSETCHAINS_ADAPTIVEPOW = 1;
fprintf(stderr,"default activate adaptivepow\n"); fprintf(stderr,"default activate adaptivepow\n");
} else fprintf(stderr,"height1 time %u vs %u\n",pindex->nTime,ADAPTIVEPOW_CHANGETO_DEFAULTON); } else fprintf(stderr,"height1 time %u vs %u\n",pindex->nTime,ADAPTIVEPOW_CHANGETO_DEFAULTON);
} //else fprintf(stderr,"cant find height 1\n"); } //else fprintf(stderr,"cant find height 1\n");*/
if ( ASSETCHAINS_CBOPRET != 0 ) if ( ASSETCHAINS_CBOPRET != 0 )
komodo_pricesinit(); komodo_pricesinit();
while (!fShutdown) while (!fShutdown)
@@ -91,7 +91,7 @@ void WaitForShutdown(boost::thread_group* threadGroup)
//fprintf(stderr,"call passport iteration\n"); //fprintf(stderr,"call passport iteration\n");
if ( ASSETCHAINS_SYMBOL[0] == 0 ) if ( ASSETCHAINS_SYMBOL[0] == 0 )
{ {
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
komodo_passport_iteration(); komodo_passport_iteration();
for (i=0; i<10; i++) for (i=0; i<10; i++)
{ {
@@ -170,19 +170,17 @@ bool AppInit(int argc, char* argv[])
try try
{ {
// Check for -testnet or -regtest parameter (Params() calls are only valid after this clause)
if (!SelectParamsFromCommandLine()) {
fprintf(stderr, "Error: Invalid combination of -regtest and -testnet.\n");
return false;
}
void komodo_args(char *argv0); void komodo_args(char *argv0);
komodo_args(argv[0]); komodo_args(argv[0]);
void chainparams_commandline();
chainparams_commandline();
fprintf(stderr,"call komodo_args.(%s) NOTARY_PUBKEY.(%s)\n",argv[0],NOTARY_PUBKEY.c_str()); fprintf(stderr,"call komodo_args.(%s) NOTARY_PUBKEY.(%s)\n",argv[0],NOTARY_PUBKEY.c_str());
while ( ASSETCHAIN_INIT == 0 )
{
//if ( komodo_is_issuer() != 0 )
// komodo_passport_iteration();
#ifdef _WIN32
boost::this_thread::sleep_for(boost::chrono::seconds(1));
#else
sleep(1);
#endif
}
printf("initialized %s at %u\n",ASSETCHAINS_SYMBOL,(uint32_t)time(NULL)); printf("initialized %s at %u\n",ASSETCHAINS_SYMBOL,(uint32_t)time(NULL));
if (!boost::filesystem::is_directory(GetDataDir(false))) if (!boost::filesystem::is_directory(GetDataDir(false)))
{ {
@@ -214,11 +212,6 @@ bool AppInit(int argc, char* argv[])
fprintf(stderr,"Error reading configuration file: %s\n", e.what()); fprintf(stderr,"Error reading configuration file: %s\n", e.what());
return false; return false;
} }
// Check for -testnet or -regtest parameter (Params() calls are only valid after this clause)
if (!SelectParamsFromCommandLine()) {
fprintf(stderr, "Error: Invalid combination of -regtest and -testnet.\n");
return false;
}
// Command-line RPC // Command-line RPC
bool fCommandLine = false; bool fCommandLine = false;

View File

@@ -56,7 +56,7 @@ one other technical note is that komodod has the insight-explorer extensions bui
#define CC_BURNPUBKEY "02deaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead" #define CC_BURNPUBKEY "02deaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddeaddead"
#define CC_MAXVINS 1024 #define CC_MAXVINS 1024
#define CC_REQUIREMENTS_MSG (KOMODO_NSPV!=0?"to use CC contracts you need to nspv_login first\n":"to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n") #define CC_REQUIREMENTS_MSG (KOMODO_NSPV_SUPERLITE?"to use CC contracts you need to nspv_login first\n":"to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n")
#define SMALLVAL 0.000000000000001 #define SMALLVAL 0.000000000000001
#define SATOSHIDEN ((uint64_t)100000000L) #define SATOSHIDEN ((uint64_t)100000000L)
@@ -292,6 +292,7 @@ extern std::vector<CPubKey> NULL_pubkeys;
std::string FinalizeCCTx(uint64_t skipmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret,std::vector<CPubKey> pubkeys = NULL_pubkeys); std::string FinalizeCCTx(uint64_t skipmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret,std::vector<CPubKey> pubkeys = NULL_pubkeys);
void SetCCunspents(std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > &unspentOutputs,char *coinaddr,bool CCflag = true); void SetCCunspents(std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > &unspentOutputs,char *coinaddr,bool CCflag = true);
void SetCCtxids(std::vector<std::pair<CAddressIndexKey, CAmount> > &addressIndex,char *coinaddr,bool CCflag = true); void SetCCtxids(std::vector<std::pair<CAddressIndexKey, CAmount> > &addressIndex,char *coinaddr,bool CCflag = true);
void SetCCtxids(std::vector<uint256> &txids,char *coinaddr,bool ccflag, uint8_t evalcode, uint256 filtertxid, uint8_t func);
int64_t NSPV_AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCmtxinfo *ptr); int64_t NSPV_AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs,struct NSPV_CCmtxinfo *ptr);
int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs); int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs);
int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs); int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs);

View File

@@ -957,7 +957,7 @@ UniValue TokenInfo(uint256 tokenid)
result.push_back(Pair("error", "cant find tokenid")); result.push_back(Pair("error", "cant find tokenid"));
return(result); return(result);
} }
if ( KOMODO_NSPV <= 0 && hashBlock.IsNull()) { if ( KOMODO_NSPV_FULLNODE && hashBlock.IsNull()) {
result.push_back(Pair("result", "error")); result.push_back(Pair("result", "error"));
result.push_back(Pair("error", "the transaction is still in mempool")); result.push_back(Pair("error", "the transaction is still in mempool"));
return(result); return(result);
@@ -1026,7 +1026,7 @@ UniValue TokenInfo(uint256 tokenid)
UniValue TokenList() UniValue TokenList()
{ {
UniValue result(UniValue::VARR); UniValue result(UniValue::VARR);
std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex; std::vector<uint256> txids;
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > addressIndexCCMarker; std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > addressIndexCCMarker;
struct CCcontract_info *cp, C; uint256 txid, hashBlock; struct CCcontract_info *cp, C; uint256 txid, hashBlock;
@@ -1043,9 +1043,9 @@ UniValue TokenList()
} }
}; };
SetCCtxids(addressIndex, cp->normaladdr,false); // find by old normal addr marker SetCCtxids(txids, cp->normaladdr,false,cp->evalcode,zeroid,'c'); // find by old normal addr marker
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it = addressIndex.begin(); it != addressIndex.end(); it++) { for (std::vector<uint256>::const_iterator it = txids.begin(); it != txids.end(); it++) {
addTokenId(it->first.txhash); addTokenId(*it);
} }
SetCCunspents(addressIndexCCMarker, cp->unspendableCCaddr,true); // find by burnable validated cc addr marker SetCCunspents(addressIndexCCMarker, cp->unspendableCCaddr,true); // find by burnable validated cc addr marker

View File

@@ -162,7 +162,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
utxovout = mtx.vin[i].prevout.n; utxovout = mtx.vin[i].prevout.n;
if ( vintx.vout[utxovout].scriptPubKey.IsPayToCryptoCondition() == 0 ) if ( vintx.vout[utxovout].scriptPubKey.IsPayToCryptoCondition() == 0 )
{ {
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
{ {
if ( SignTx(mtx,i,vintx.vout[utxovout].nValue,vintx.vout[utxovout].scriptPubKey) == 0 ) if ( SignTx(mtx,i,vintx.vout[utxovout].nValue,vintx.vout[utxovout].scriptPubKey) == 0 )
fprintf(stderr,"signing error for vini.%d of %llx\n",i,(long long)vinimask); fprintf(stderr,"signing error for vini.%d of %llx\n",i,(long long)vinimask);
@@ -340,11 +340,12 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
void NSPV_CCunspents(std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > &unspentOutputs,char *coinaddr,bool ccflag); void NSPV_CCunspents(std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > &unspentOutputs,char *coinaddr,bool ccflag);
void NSPV_CCtxids(std::vector<std::pair<CAddressIndexKey, CAmount> > &txids,char *coinaddr,bool ccflag); void NSPV_CCtxids(std::vector<std::pair<CAddressIndexKey, CAmount> > &txids,char *coinaddr,bool ccflag);
void NSPV_CCtxids(std::vector<uint256> &txids,char *coinaddr,bool ccflag, uint8_t evalcode,uint256 filtertxid, uint8_t func);
void SetCCunspents(std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > &unspentOutputs,char *coinaddr,bool ccflag) void SetCCunspents(std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > &unspentOutputs,char *coinaddr,bool ccflag)
{ {
int32_t type=0,i,n; char *ptr; std::string addrstr; uint160 hashBytes; std::vector<std::pair<uint160, int> > addresses; int32_t type=0,i,n; char *ptr; std::string addrstr; uint160 hashBytes; std::vector<std::pair<uint160, int> > addresses;
if ( KOMODO_NSPV > 0 ) if ( KOMODO_NSPV_SUPERLITE )
{ {
NSPV_CCunspents(unspentOutputs,coinaddr,ccflag); NSPV_CCunspents(unspentOutputs,coinaddr,ccflag);
return; return;
@@ -368,7 +369,7 @@ void SetCCunspents(std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValu
void SetCCtxids(std::vector<std::pair<CAddressIndexKey, CAmount> > &addressIndex,char *coinaddr,bool ccflag) void SetCCtxids(std::vector<std::pair<CAddressIndexKey, CAmount> > &addressIndex,char *coinaddr,bool ccflag)
{ {
int32_t type=0,i,n; char *ptr; std::string addrstr; uint160 hashBytes; std::vector<std::pair<uint160, int> > addresses; int32_t type=0,i,n; char *ptr; std::string addrstr; uint160 hashBytes; std::vector<std::pair<uint160, int> > addresses;
if ( KOMODO_NSPV > 0 ) if ( KOMODO_NSPV_SUPERLITE )
{ {
NSPV_CCtxids(addressIndex,coinaddr,ccflag); NSPV_CCtxids(addressIndex,coinaddr,ccflag);
return; return;
@@ -389,6 +390,32 @@ void SetCCtxids(std::vector<std::pair<CAddressIndexKey, CAmount> > &addressIndex
} }
} }
void SetCCtxids(std::vector<uint256> &txids,char *coinaddr,bool ccflag, uint8_t evalcode, uint256 filtertxid, uint8_t func)
{
int32_t type=0,i,n; char *ptr; std::string addrstr; uint160 hashBytes; std::vector<std::pair<uint160, int> > addresses;
std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex;
if ( KOMODO_NSPV_SUPERLITE )
{
NSPV_CCtxids(txids,coinaddr,ccflag,evalcode,filtertxid,func);
return;
}
n = (int32_t)strlen(coinaddr);
addrstr.resize(n+1);
ptr = (char *)addrstr.data();
for (i=0; i<=n; i++)
ptr[i] = coinaddr[i];
CBitcoinAddress address(addrstr);
if ( address.GetIndexKey(hashBytes, type, ccflag) == 0 )
return;
addresses.push_back(std::make_pair(hashBytes,type));
for (std::vector<std::pair<uint160, int> >::iterator it = addresses.begin(); it != addresses.end(); it++)
{
if ( GetAddressIndex((*it).first, (*it).second, addressIndex) == 0 )
return;
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it1=addressIndex.begin(); it1!=addressIndex.end(); it1++) txids.push_back(it1->first.txhash);
}
}
int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout,int32_t CCflag) int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout,int32_t CCflag)
{ {
uint256 txid; std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs; uint256 txid; std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
@@ -555,7 +582,7 @@ int32_t CC_vinselect(int32_t *aboveip,int64_t *abovep,int32_t *belowip,int64_t *
int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs) int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs)
{ {
int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; uint256 txid,hashBlock; std::vector<COutput> vecOutputs; CTransaction tx; struct CC_utxo *utxos,*up; int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; uint256 txid,hashBlock; std::vector<COutput> vecOutputs; CTransaction tx; struct CC_utxo *utxos,*up;
if ( KOMODO_NSPV > 0 ) if ( KOMODO_NSPV_SUPERLITE )
return(NSPV_AddNormalinputs(mtx,mypk,total,maxinputs,&NSPV_U)); return(NSPV_AddNormalinputs(mtx,mypk,total,maxinputs,&NSPV_U));
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
assert(pwalletMain != NULL); assert(pwalletMain != NULL);
@@ -652,7 +679,7 @@ int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinput
{ {
int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; struct CC_utxo *utxos,*up; int32_t abovei,belowi,ind,vout,i,n = 0; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; struct CC_utxo *utxos,*up;
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs; std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
if ( KOMODO_NSPV > 0 ) if ( KOMODO_NSPV_SUPERLITE )
return(NSPV_AddNormalinputs(mtx,pubkey2pk(Mypubkey()),total,maxinputs,&NSPV_U)); return(NSPV_AddNormalinputs(mtx,pubkey2pk(Mypubkey()),total,maxinputs,&NSPV_U));
utxos = (struct CC_utxo *)calloc(CC_MAXVINS,sizeof(*utxos)); utxos = (struct CC_utxo *)calloc(CC_MAXVINS,sizeof(*utxos));
if ( maxinputs > CC_MAXVINS ) if ( maxinputs > CC_MAXVINS )

View File

@@ -450,7 +450,7 @@ extern uint32_t NSPV_logintime;
bool Myprivkey(uint8_t myprivkey[]) bool Myprivkey(uint8_t myprivkey[])
{ {
char coinaddr[64],checkaddr[64]; std::string strAddress; char *dest; int32_t i,n; CBitcoinAddress address; CKeyID keyID; CKey vchSecret; uint8_t buf33[33]; char coinaddr[64],checkaddr[64]; std::string strAddress; char *dest; int32_t i,n; CBitcoinAddress address; CKeyID keyID; CKey vchSecret; uint8_t buf33[33];
if ( KOMODO_NSPV > 0 ) if ( KOMODO_NSPV_SUPERLITE )
{ {
if ( NSPV_logintime == 0 || time(NULL) > NSPV_logintime+NSPV_AUTOLOGOUT ) if ( NSPV_logintime == 0 || time(NULL) > NSPV_logintime+NSPV_AUTOLOGOUT )
{ {
@@ -590,7 +590,7 @@ int32_t NSPV_coinaddr_inmempool(char const *logcategory,char *coinaddr,uint8_t C
int32_t myIs_coinaddr_inmempoolvout(char const *logcategory,char *coinaddr) int32_t myIs_coinaddr_inmempoolvout(char const *logcategory,char *coinaddr)
{ {
int32_t i,n; char destaddr[64]; int32_t i,n; char destaddr[64];
if ( KOMODO_NSPV > 0 ) if ( KOMODO_NSPV_SUPERLITE )
return(NSPV_coinaddr_inmempool(logcategory,coinaddr,1)); return(NSPV_coinaddr_inmempool(logcategory,coinaddr,1));
BOOST_FOREACH(const CTxMemPoolEntry &e,mempool.mapTx) BOOST_FOREACH(const CTxMemPoolEntry &e,mempool.mapTx)
{ {
@@ -619,7 +619,7 @@ int32_t myGet_mempool_txs(std::vector<CTransaction> &txs,uint8_t evalcode,uint8_
{ {
int i=0; int i=0;
if ( KOMODO_NSPV > 0 ) if ( KOMODO_NSPV_SUPERLITE )
{ {
CTransaction tx; uint256 hashBlock; CTransaction tx; uint256 hashBlock;
@@ -664,6 +664,16 @@ uint256 BitcoinGetProofMerkleRoot(const std::vector<uint8_t> &proofData, std::ve
return merkleBlock.txn.ExtractMatches(txids); return merkleBlock.txn.ExtractMatches(txids);
} }
extern struct NSPV_inforesp NSPV_inforesult;
int32_t komodo_get_current_height()
{
if ( KOMODO_NSPV_SUPERLITE )
{
return (NSPV_inforesult.height);
}
else return chainActive.LastTip()->GetHeight();
}
bool komodo_txnotarizedconfirmed(uint256 txid) bool komodo_txnotarizedconfirmed(uint256 txid)
{ {
char str[65]; char str[65];
@@ -673,7 +683,7 @@ bool komodo_txnotarizedconfirmed(uint256 txid)
CBlockIndex *pindex; CBlockIndex *pindex;
char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp;
if (KOMODO_NSPV!=0) if ( KOMODO_NSPV_SUPERLITE )
{ {
if ( NSPV_myGetTransaction(txid,tx,hashBlock,txheight,currentheight) == 0 ) if ( NSPV_myGetTransaction(txid,tx,hashBlock,txheight,currentheight) == 0 )
{ {

View File

@@ -787,22 +787,20 @@ std::string ChannelRefund(uint64_t txfee,uint256 opentxid,uint256 closetxid)
UniValue ChannelsList() UniValue ChannelsList()
{ {
UniValue result(UniValue::VOBJ); std::vector<std::pair<CAddressIndexKey, CAmount> > txids; struct CCcontract_info *cp,C; uint256 txid,hashBlock,tmp_txid,param3,tokenid; UniValue result(UniValue::VOBJ); std::vector<uint256> txids; struct CCcontract_info *cp,C; uint256 txid,hashBlock,tmp_txid,param3,tokenid;
CTransaction tx; char myCCaddr[65],addr[65],str[256]; CPubKey mypk,srcpub,destpub; int32_t vout,numvouts,param1; CTransaction tx; char myCCaddr[65],addr[65],str[256]; CPubKey mypk,srcpub,destpub; int32_t vout,numvouts,param1;
int64_t nValue,param2; int64_t nValue,param2;
cp = CCinit(&C,EVAL_CHANNELS); cp = CCinit(&C,EVAL_CHANNELS);
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
GetCCaddress(cp,myCCaddr,mypk); GetCCaddress(cp,myCCaddr,mypk);
SetCCtxids(txids,myCCaddr,true); SetCCtxids(txids,myCCaddr,true,EVAL_CHANNELS,zeroid,'O');
result.push_back(Pair("result","success")); result.push_back(Pair("result","success"));
result.push_back(Pair("name","Channels List")); result.push_back(Pair("name","Channels List"));
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=txids.begin(); it!=txids.end(); it++) for (std::vector<uint256>::const_iterator it=txids.begin(); it!=txids.end(); it++)
{ {
txid = it->first.txhash; txid = *it;
vout = (int32_t)it->first.index; if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 )
nValue = (int64_t)it->second;
if ( (vout == 1 || vout == 2) && nValue == CC_MARKER_VALUE && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 )
{ {
if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,param1,param2,param3) == 'O') if (DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,param1,param2,param3) == 'O')
{ {
@@ -820,7 +818,7 @@ UniValue ChannelsInfo(uint256 channeltxid)
UniValue result(UniValue::VOBJ),array(UniValue::VARR); CTransaction tx,opentx; uint256 txid,tmp_txid,hashBlock,param3,opentxid,hashchain,tokenid; UniValue result(UniValue::VOBJ),array(UniValue::VARR); CTransaction tx,opentx; uint256 txid,tmp_txid,hashBlock,param3,opentxid,hashchain,tokenid;
struct CCcontract_info *cp,C; char CCaddr[65],addr[65],str[512]; int32_t vout,numvouts,param1,numpayments; struct CCcontract_info *cp,C; char CCaddr[65],addr[65],str[512]; int32_t vout,numvouts,param1,numpayments;
int64_t param2,payment; CPubKey srcpub,destpub,mypk; int64_t param2,payment; CPubKey srcpub,destpub,mypk;
std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex; std::vector<CTransaction> txs; std::vector<uint256> txids; std::vector<CTransaction> txs;
cp = CCinit(&C,EVAL_CHANNELS); cp = CCinit(&C,EVAL_CHANNELS);
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
@@ -846,10 +844,10 @@ UniValue ChannelsInfo(uint256 channeltxid)
result.push_back(Pair("Amount (satoshi)",i64tostr(param1*param2))); result.push_back(Pair("Amount (satoshi)",i64tostr(param1*param2)));
} }
GetCCaddress(cp,CCaddr,mypk); GetCCaddress(cp,CCaddr,mypk);
SetCCtxids(addressIndex,CCaddr,true); SetCCtxids(txids,CCaddr,true,EVAL_CHANNELS,channeltxid,0);
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) for (std::vector<uint256>::const_iterator it=txids.begin(); it!=txids.end(); it++)
{ {
if (myGetTransaction(it->first.txhash,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 && it->second==CC_MARKER_VALUE && if (myGetTransaction(*it,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 &&
DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,param1,param2,param3)!=0 && (tmp_txid==channeltxid || tx.GetHash()==channeltxid)) DecodeChannelsOpRet(tx.vout[numvouts-1].scriptPubKey,tokenid,tmp_txid,srcpub,destpub,param1,param2,param3)!=0 && (tmp_txid==channeltxid || tx.GetHash()==channeltxid))
txs.push_back(tx); txs.push_back(tx);
} }

View File

@@ -1224,9 +1224,9 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit
bool DicePlanExists(CScript &fundingPubKey,uint256 &fundingtxid,struct CCcontract_info *cp,uint64_t refsbits,CPubKey dicepk,int64_t &minbet,int64_t &maxbet,int64_t &maxodds,int64_t &timeoutblocks) bool DicePlanExists(CScript &fundingPubKey,uint256 &fundingtxid,struct CCcontract_info *cp,uint64_t refsbits,CPubKey dicepk,int64_t &minbet,int64_t &maxbet,int64_t &maxodds,int64_t &timeoutblocks)
{ {
char CCaddr[64]; uint64_t sbits=0; uint256 txid,hashBlock; CTransaction tx; char CCaddr[64]; uint64_t sbits=0; uint256 txid,hashBlock; CTransaction tx;
std::vector<std::pair<CAddressIndexKey, CAmount> > txids; std::vector<uint256> txids;
GetCCaddress(cp,CCaddr,dicepk); GetCCaddress(cp,CCaddr,dicepk);
SetCCtxids(txids,cp->normaladdr,false); SetCCtxids(txids,cp->normaladdr,false,cp->evalcode,zeroid,'F');
if ( fundingtxid != zeroid ) // avoid scan unless creating new funding plan if ( fundingtxid != zeroid ) // avoid scan unless creating new funding plan
{ {
//fprintf(stderr,"check fundingtxid\n"); //fprintf(stderr,"check fundingtxid\n");
@@ -1240,10 +1240,9 @@ bool DicePlanExists(CScript &fundingPubKey,uint256 &fundingtxid,struct CCcontrac
} else fprintf(stderr,"couldnt get funding tx\n"); } else fprintf(stderr,"couldnt get funding tx\n");
return(false); return(false);
} }
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=txids.begin(); it!=txids.end(); it++) for (std::vector<uint256>::const_iterator it=txids.begin(); it!=txids.end(); it++)
{ {
//int height = it->first.blockHeight; txid = *it;
txid = it->first.txhash;
if ( fundingtxid != zeroid && txid != fundingtxid ) if ( fundingtxid != zeroid && txid != fundingtxid )
continue; continue;
if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout.size() > 0 && ConstrainVout(tx.vout[0],1,CCaddr,0) != 0 ) if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout.size() > 0 && ConstrainVout(tx.vout[0],1,CCaddr,0) != 0 )
@@ -1320,12 +1319,12 @@ UniValue DiceInfo(uint256 diceid)
UniValue DiceList() UniValue DiceList()
{ {
UniValue result(UniValue::VARR); std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock; CTransaction vintx; uint64_t sbits; int64_t minbet,maxbet,maxodds,timeoutblocks; char str[65]; UniValue result(UniValue::VARR); std::vector<uint256> txids; struct CCcontract_info *cp,C; uint256 txid,hashBlock; CTransaction vintx; uint64_t sbits; int64_t minbet,maxbet,maxodds,timeoutblocks; char str[65];
cp = CCinit(&C,EVAL_DICE); cp = CCinit(&C,EVAL_DICE);
SetCCtxids(addressIndex,cp->normaladdr,false); SetCCtxids(txids,cp->normaladdr,false,cp->evalcode,zeroid,'F');
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) for (std::vector<uint256>::const_iterator it=txids.begin(); it!=txids.end(); it++)
{ {
txid = it->first.txhash; txid = *it;
if ( myGetTransaction(txid,vintx,hashBlock) != 0 ) if ( myGetTransaction(txid,vintx,hashBlock) != 0 )
{ {
if ( vintx.vout.size() > 0 && DecodeDiceFundingOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,sbits,minbet,maxbet,maxodds,timeoutblocks) != 0 ) if ( vintx.vout.size() > 0 && DecodeDiceFundingOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,sbits,minbet,maxbet,maxodds,timeoutblocks) != 0 )

View File

@@ -3580,16 +3580,16 @@ int32_t dilithium_registrationpub33(char *pkaddr,CPubKey &pub33,uint256 txid)
void dilithium_handleinit(struct CCcontract_info *cp) void dilithium_handleinit(struct CCcontract_info *cp)
{ {
static int32_t didinit; static int32_t didinit;
std::vector<std::pair<CAddressIndexKey, CAmount> > txids; struct dilithium_handle *hashstr; CPubKey dilithiumpk,pub33; uint256 txid,hashBlock; CTransaction txi; int32_t numvouts; std::vector<uint8_t> bigpub; std::string handle; char CCaddr[64]; std::vector<uint256> txids; struct dilithium_handle *hashstr; CPubKey dilithiumpk,pub33; uint256 txid,hashBlock; CTransaction txi; int32_t numvouts; std::vector<uint8_t> bigpub; std::string handle; char CCaddr[64];
if ( didinit != 0 ) if ( didinit != 0 )
return; return;
pthread_mutex_init(&DILITHIUM_MUTEX,NULL); pthread_mutex_init(&DILITHIUM_MUTEX,NULL);
dilithiumpk = GetUnspendable(cp,0); dilithiumpk = GetUnspendable(cp,0);
GetCCaddress(cp,CCaddr,dilithiumpk); GetCCaddress(cp,CCaddr,dilithiumpk);
SetCCtxids(txids,CCaddr,true); SetCCtxids(txids,CCaddr,true,cp->evalcode,zeroid,'R');
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=txids.begin(); it!=txids.end(); it++) for (std::vector<uint256>::const_iterator it=txids.begin(); it!=txids.end(); it++)
{ {
txid = it->first.txhash; txid = *it;
if ( myGetTransaction(txid,txi,hashBlock) != 0 && (numvouts= txi.vout.size()) > 1 ) if ( myGetTransaction(txid,txi,hashBlock) != 0 && (numvouts= txi.vout.size()) > 1 )
{ {
if ( dilithium_registeropretdecode(handle,pub33,bigpub,txi.vout[numvouts-1].scriptPubKey) == 'R' ) if ( dilithium_registeropretdecode(handle,pub33,bigpub,txi.vout[numvouts-1].scriptPubKey) == 'R' )

View File

@@ -1664,29 +1664,25 @@ UniValue games_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
UniValue games_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue games_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
{ {
UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); uint256 txid,hashBlock,gametxid,tokenid,playertxid; int32_t vout,maxplayers,gameheight,numvouts; CPubKey gamespk,mypk; char coinaddr[64]; CTransaction tx,gametx; int64_t buyin; UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); uint256 txid,hashBlock,gametxid,tokenid,playertxid; int32_t vout,maxplayers,gameheight,numvouts; CPubKey gamespk,mypk; char coinaddr[64]; CTransaction tx,gametx; int64_t buyin;
std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex; std::vector<uint256> txids;
gamespk = GetUnspendable(cp,0); gamespk = GetUnspendable(cp,0);
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
GetCCaddress1of2(cp,coinaddr,gamespk,mypk); GetCCaddress1of2(cp,coinaddr,gamespk,mypk);
SetCCtxids(addressIndex,coinaddr,true); SetCCtxids(txids,coinaddr,true,cp->evalcode,zeroid,'R');
games_univalue(result,"games",-1,-1); games_univalue(result,"games",-1,-1);
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) for (std::vector<uint256>::const_iterator it=txids.begin(); it!=txids.end(); it++)
{ {
txid = it->first.txhash; txid = *it;
vout = (int32_t)it->first.index;
//char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN);
if ( vout == 0 ) if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 )
{ {
if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) if ( games_registeropretdecode(gametxid,tokenid,playertxid,tx.vout[numvouts-1].scriptPubKey) == 'R' )
{ {
if ( games_registeropretdecode(gametxid,tokenid,playertxid,tx.vout[numvouts-1].scriptPubKey) == 'R' ) if ( games_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0) == 0 )
{ {
if ( games_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0) == 0 ) if ( CCgettxout(txid,vout,1,0) < 0 )
{ b.push_back(gametxid.GetHex());
if ( CCgettxout(txid,vout,1,0) < 0 ) else a.push_back(gametxid.GetHex());
b.push_back(gametxid.GetHex());
else a.push_back(gametxid.GetHex());
}
} }
} }
} }

View File

@@ -481,13 +481,13 @@ int32_t GatewaysBindExists(struct CCcontract_info *cp,CPubKey gatewayspk,uint256
{ {
char markeraddr[64],depositaddr[64]; std::string coin; int32_t numvouts; int64_t totalsupply; uint256 tokenid,oracletxid,hashBlock; char markeraddr[64],depositaddr[64]; std::string coin; int32_t numvouts; int64_t totalsupply; uint256 tokenid,oracletxid,hashBlock;
uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector<CPubKey> pubkeys; CTransaction tx; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector<CPubKey> pubkeys; CTransaction tx;
std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex; std::vector<uint256> txids;
_GetCCaddress(markeraddr,EVAL_GATEWAYS,gatewayspk); _GetCCaddress(markeraddr,EVAL_GATEWAYS,gatewayspk);
SetCCtxids(addressIndex,markeraddr,true); SetCCtxids(txids,markeraddr,true,EVAL_GATEWAYS,zeroid,'B');
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) for (std::vector<uint256>::const_iterator it=txids.begin(); it!=txids.end(); it++)
{ {
if ( myGetTransaction(it->first.txhash,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 && DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey)=='B' ) if ( myGetTransaction(*it,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 && DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey)=='B' )
{ {
if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) == 'B' ) if ( DecodeGatewaysBindOpRet(depositaddr,tx.vout[numvouts-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) == 'B' )
{ {
@@ -629,12 +629,10 @@ bool GatewaysValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &
return eval->Invalid("deposit amount greater then bind total supply"); return eval->Invalid("deposit amount greater then bind total supply");
else if (komodo_txnotarizedconfirmed(deposittxid) == false) else if (komodo_txnotarizedconfirmed(deposittxid) == false)
return eval->Invalid("gatewaysdeposit tx is not yet confirmed(notarised)!"); return eval->Invalid("gatewaysdeposit tx is not yet confirmed(notarised)!");
else if (IsCCInput(tx.vin[0].scriptSig) != 0) else if (tx.vin.size()>0)
return eval->Invalid("vin.0 is normal for gatewaysclaim!");
else if (tx.vin.size()>2)
{ {
i=1; i=0;
while (i<=tx.vin.size()-2) while (i<tx.vin.size()-1)
{ {
if (IsCCInput(tx.vin[i].scriptSig)==0) return eval->Invalid("vin."+std::to_string(i)+" is CC for gatewaysclaim!"); if (IsCCInput(tx.vin[i].scriptSig)==0) return eval->Invalid("vin."+std::to_string(i)+" is CC for gatewaysclaim!");
i++; i++;
@@ -1108,18 +1106,15 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
if ( AddNormalinputs(mtx,mypk,txfee,1) > 0 ) if ((inputs=AddGatewaysInputs(cp, mtx, gatewayspk, bindtxid, amount, 60)) > 0)
{ {
if ((inputs=AddGatewaysInputs(cp, mtx, gatewayspk, bindtxid, amount, 60)) > 0) if ( inputs > amount ) CCchange = (inputs - amount);
{ mtx.vin.push_back(CTxIn(deposittxid,0,CScript()));
if ( inputs > amount ) CCchange = (inputs - amount); mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS,amount,destpub));
mtx.vin.push_back(CTxIn(deposittxid,0,CScript())); if ( CCchange != 0 ) mtx.vout.push_back(MakeTokensCC1vout(EVAL_GATEWAYS,CCchange,gatewayspk));
mtx.vout.push_back(MakeCC1vout(EVAL_TOKENS,amount,destpub)); return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysClaimOpRet('C',tokenid,bindtxid,refcoin,deposittxid,destpub,amount)));
if ( CCchange != 0 ) mtx.vout.push_back(MakeTokensCC1vout(EVAL_GATEWAYS,CCchange,gatewayspk));
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeGatewaysClaimOpRet('C',tokenid,bindtxid,refcoin,deposittxid,destpub,amount)));
}
} }
CCerror = strprintf("cant find enough inputs or mismatched total"); CCerror = strprintf("cant find enough tokens in gateways address for given amount");
LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl); LOGSTREAM("gatewayscc",CCLOG_INFO, stream << CCerror << std::endl);
return(""); return("");
} }
@@ -1684,12 +1679,12 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin)
UniValue GatewaysList() UniValue GatewaysList()
{ {
UniValue result(UniValue::VARR); std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock,oracletxid,tokenid; CTransaction vintx; std::string coin; int64_t totalsupply; char str[65],depositaddr[64]; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector<CPubKey> pubkeys; UniValue result(UniValue::VARR); std::vector<uint256> txids; struct CCcontract_info *cp,C; uint256 txid,hashBlock,oracletxid,tokenid; CTransaction vintx; std::string coin; int64_t totalsupply; char str[65],depositaddr[64]; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector<CPubKey> pubkeys;
cp = CCinit(&C,EVAL_GATEWAYS); cp = CCinit(&C,EVAL_GATEWAYS);
SetCCtxids(addressIndex,cp->unspendableCCaddr,true); SetCCtxids(txids,cp->unspendableCCaddr,true,EVAL_GATEWAYS,zeroid,'B');
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) for (std::vector<uint256>::const_iterator it=txids.begin(); it!=txids.end(); it++)
{ {
txid = it->first.txhash; txid = *it;
if ( myGetTransaction(txid,vintx,hashBlock) != 0 ) if ( myGetTransaction(txid,vintx,hashBlock) != 0 )
{ {
if ( vintx.vout.size() > 0 && DecodeGatewaysBindOpRet(depositaddr,vintx.vout[vintx.vout.size()-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 0 ) if ( vintx.vout.size() > 0 && DecodeGatewaysBindOpRet(depositaddr,vintx.vout[vintx.vout.size()-1].scriptPubKey,tokenid,coin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 0 )

View File

@@ -260,13 +260,13 @@ int32_t ImportGatewayBindExists(struct CCcontract_info *cp,CPubKey importgateway
{ {
char markeraddr[64],burnaddr[64]; std::string coin; int32_t numvouts; int64_t totalsupply; uint256 tokenid,oracletxid,hashBlock; char markeraddr[64],burnaddr[64]; std::string coin; int32_t numvouts; int64_t totalsupply; uint256 tokenid,oracletxid,hashBlock;
uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector<CPubKey> pubkeys; CTransaction tx; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector<CPubKey> pubkeys; CTransaction tx;
std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex; std::vector<uint256> txids;
_GetCCaddress(markeraddr,EVAL_IMPORTGATEWAY,importgatewaypk); _GetCCaddress(markeraddr,EVAL_IMPORTGATEWAY,importgatewaypk);
SetCCtxids(addressIndex,markeraddr,true); SetCCtxids(txids,markeraddr,true,cp->evalcode,zeroid,'B');
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) for (std::vector<uint256>::const_iterator it=txids.begin(); it!=txids.end(); it++)
{ {
if ( myGetTransaction(it->first.txhash,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 && DecodeImportGatewayOpRet(tx.vout[numvouts-1].scriptPubKey)=='B' ) if ( myGetTransaction(*it,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 && DecodeImportGatewayOpRet(tx.vout[numvouts-1].scriptPubKey)=='B' )
{ {
if ( DecodeImportGatewayBindOpRet(burnaddr,tx.vout[numvouts-1].scriptPubKey,coin,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) == 'B' ) if ( DecodeImportGatewayBindOpRet(burnaddr,tx.vout[numvouts-1].scriptPubKey,coin,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) == 'B' )
{ {
@@ -1172,14 +1172,14 @@ UniValue ImportGatewayProcessedWithdraws(uint256 bindtxid,std::string refcoin)
UniValue ImportGatewayList() UniValue ImportGatewayList()
{ {
UniValue result(UniValue::VARR); std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex; UniValue result(UniValue::VARR); std::vector<uint256> txids;
struct CCcontract_info *cp,C; uint256 txid,hashBlock,oracletxid; CTransaction vintx; std::string coin; struct CCcontract_info *cp,C; uint256 txid,hashBlock,oracletxid; CTransaction vintx; std::string coin;
char str[65],burnaddr[64]; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector<CPubKey> pubkeys; char str[65],burnaddr[64]; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector<CPubKey> pubkeys;
cp = CCinit(&C,EVAL_IMPORTGATEWAY); cp = CCinit(&C,EVAL_IMPORTGATEWAY);
SetCCtxids(addressIndex,cp->unspendableCCaddr,true); SetCCtxids(txids,cp->unspendableCCaddr,true,cp->evalcode,zeroid,'B');
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) for (std::vector<uint256>::const_iterator it=txids.begin(); it!=txids.end(); it++)
{ {
txid = it->first.txhash; txid = *it;
if ( myGetTransaction(txid,vintx,hashBlock) != 0 ) if ( myGetTransaction(txid,vintx,hashBlock) != 0 )
{ {
if ( vintx.vout.size() > 0 && DecodeImportGatewayBindOpRet(burnaddr,vintx.vout[vintx.vout.size()-1].scriptPubKey,coin,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 0 ) if ( vintx.vout.size() > 0 && DecodeImportGatewayBindOpRet(burnaddr,vintx.vout[vintx.vout.size()-1].scriptPubKey,coin,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 0 )

View File

@@ -264,12 +264,12 @@ UniValue LottoInfo(uint256 lottoid)
UniValue LottoList() UniValue LottoList()
{ {
UniValue result(UniValue::VARR); std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock,hentropy; CTransaction vintx; uint64_t sbits; int32_t ticketsize,odds,firstheight,period; char str[65]; UniValue result(UniValue::VARR); std::vector<uint256> txids; struct CCcontract_info *cp,C; uint256 txid,hashBlock,hentropy; CTransaction vintx; uint64_t sbits; int32_t ticketsize,odds,firstheight,period; char str[65];
cp = CCinit(&C,EVAL_LOTTO); cp = CCinit(&C,EVAL_LOTTO);
SetCCtxids(addressIndex,cp->normaladdr,true); SetCCtxids(txids,cp->normaladdr,true,cp->evalcode,zeroid,'F');
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) for (std::vector<uint256>::const_iterator it=txids.begin(); it!=txids.end(); it++)
{ {
txid = it->first.txhash; txid = *it;
if ( myGetTransaction(txid,vintx,hashBlock) != 0 ) if ( myGetTransaction(txid,vintx,hashBlock) != 0 )
{ {
if ( vintx.vout.size() > 0 && DecodeLottoFundingOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,sbits,ticketsize,odds,firstheight,period,hentropy) == 'F' ) if ( vintx.vout.size() > 0 && DecodeLottoFundingOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,sbits,ticketsize,odds,firstheight,period,hentropy) == 'F' )

View File

@@ -92,7 +92,7 @@
vout.n-1: opreturn with oracletxid, prevbatontxid and data in proper format vout.n-1: opreturn with oracletxid, prevbatontxid and data in proper format
*/ */
extern int32_t komodo_currentheight(); extern int32_t komodo_get_current_height();
#define PUBKEY_SPOOFING_FIX_ACTIVATION 1563148800 #define PUBKEY_SPOOFING_FIX_ACTIVATION 1563148800
#define CC_MARKER_VALUE 10000 #define CC_MARKER_VALUE 10000
@@ -641,6 +641,7 @@ bool OraclesDataValidate(struct CCcontract_info *cp,Eval* eval,const CTransactio
int32_t GetLatestTimestamp(int32_t height) int32_t GetLatestTimestamp(int32_t height)
{ {
if ( KOMODO_NSPV_SUPERLITE ) return (NSPV_blocktime(height));
return(komodo_heightstamp(height)); return(komodo_heightstamp(height));
} }
@@ -791,13 +792,13 @@ int64_t AddOracleInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,uint
int64_t LifetimeOraclesFunds(struct CCcontract_info *cp,uint256 oracletxid,CPubKey publisher) int64_t LifetimeOraclesFunds(struct CCcontract_info *cp,uint256 oracletxid,CPubKey publisher)
{ {
char coinaddr[64]; CPubKey pk; int64_t total=0,num; uint256 txid,hashBlock,subtxid; CTransaction subtx; char coinaddr[64]; CPubKey pk; int64_t total=0,num; uint256 txid,hashBlock,subtxid; CTransaction subtx;
std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex; std::vector<uint256> txids;
GetCCaddress(cp,coinaddr,publisher); GetCCaddress(cp,coinaddr,publisher);
SetCCtxids(addressIndex,coinaddr,true); SetCCtxids(txids,coinaddr,true,cp->evalcode,oracletxid,'S');
//fprintf(stderr,"scan lifetime of %s\n",coinaddr); //fprintf(stderr,"scan lifetime of %s\n",coinaddr);
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) for (std::vector<uint256>::const_iterator it=txids.begin(); it!=txids.end(); it++)
{ {
txid = it->first.txhash; txid = *it;
if ( myGetTransaction(txid,subtx,hashBlock) != 0 ) if ( myGetTransaction(txid,subtx,hashBlock) != 0 )
{ {
if ( subtx.vout.size() > 0 && DecodeOraclesOpRet(subtx.vout[subtx.vout.size()-1].scriptPubKey,subtxid,pk,num) == 'S' && subtxid == oracletxid && pk == publisher ) if ( subtx.vout.size() > 0 && DecodeOraclesOpRet(subtx.vout[subtx.vout.size()-1].scriptPubKey,subtxid,pk,num) == 'S' && subtxid == oracletxid && pk == publisher )
@@ -895,7 +896,7 @@ std::string OracleFund(int64_t txfee,uint256 oracletxid)
CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight()); CMutableTransaction mtx = CreateNewContextualCMutableTransaction(Params().GetConsensus(), komodo_nextheight());
CPubKey mypk,oraclespk; struct CCcontract_info *cp,C; CPubKey mypk,oraclespk; struct CCcontract_info *cp,C;
if (GetLatestTimestamp(komodo_currentheight())<PUBKEY_SPOOFING_FIX_ACTIVATION) if (GetLatestTimestamp(komodo_get_current_height())<PUBKEY_SPOOFING_FIX_ACTIVATION)
{ {
CCerror = strprintf("oraclesfund not active yet, activation scheduled for July 15th"); CCerror = strprintf("oraclesfund not active yet, activation scheduled for July 15th");
fprintf(stderr,"%s\n", CCerror.c_str() ); fprintf(stderr,"%s\n", CCerror.c_str() );
@@ -935,7 +936,7 @@ std::string OracleRegister(int64_t txfee,uint256 oracletxid,int64_t datafee)
markerpubkey = CCtxidaddr(markeraddr,oracletxid); markerpubkey = CCtxidaddr(markeraddr,oracletxid);
if (AddNormalinputs(mtx,mypk,3*txfee,4)) if (AddNormalinputs(mtx,mypk,3*txfee,4))
{ {
if (GetLatestTimestamp(komodo_currentheight())>PUBKEY_SPOOFING_FIX_ACTIVATION && AddMyOraclesFunds(cp,mtx,mypk,oracletxid)!=CC_MARKER_VALUE) if (GetLatestTimestamp(komodo_get_current_height())>PUBKEY_SPOOFING_FIX_ACTIVATION && AddMyOraclesFunds(cp,mtx,mypk,oracletxid)!=CC_MARKER_VALUE)
{ {
CCerror = strprintf("error adding inputs from your Oracles CC address, please fund it first with oraclesfund rpc!"); CCerror = strprintf("error adding inputs from your Oracles CC address, please fund it first with oraclesfund rpc!");
fprintf(stderr,"%s\n", CCerror.c_str() ); fprintf(stderr,"%s\n", CCerror.c_str() );
@@ -943,7 +944,7 @@ std::string OracleRegister(int64_t txfee,uint256 oracletxid,int64_t datafee)
} }
mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(markerpubkey)) << OP_CHECKSIG)); mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(markerpubkey)) << OP_CHECKSIG));
mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,batonpk)); mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,batonpk));
if (GetLatestTimestamp(komodo_currentheight())>PUBKEY_SPOOFING_FIX_ACTIVATION) mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); if (GetLatestTimestamp(komodo_get_current_height())>PUBKEY_SPOOFING_FIX_ACTIVATION) mtx.vout.push_back(CTxOut(txfee,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG));
return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeOraclesOpRet('R',oracletxid,mypk,datafee))); return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeOraclesOpRet('R',oracletxid,mypk,datafee)));
} }
CCerror = strprintf("error adding normal inputs"); CCerror = strprintf("error adding normal inputs");
@@ -1096,7 +1097,7 @@ UniValue OracleDataSamples(uint256 reforacletxid,char* batonaddr,int32_t num)
{ {
UniValue result(UniValue::VOBJ),b(UniValue::VARR); CTransaction tx,oracletx; uint256 txid,hashBlock,btxid,oracletxid; UniValue result(UniValue::VOBJ),b(UniValue::VARR); CTransaction tx,oracletx; uint256 txid,hashBlock,btxid,oracletxid;
CPubKey pk; std::string name,description,format; int32_t numvouts,n=0,vout; std::vector<uint8_t> data; char *formatstr = 0; CPubKey pk; std::string name,description,format; int32_t numvouts,n=0,vout; std::vector<uint8_t> data; char *formatstr = 0;
std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex; int64_t nValue; std::vector<uint256> txids; int64_t nValue;
result.push_back(Pair("result","success")); result.push_back(Pair("result","success"));
if ( myGetTransaction(reforacletxid,oracletx,hashBlock) != 0 && (numvouts=oracletx.vout.size()) > 0 ) if ( myGetTransaction(reforacletxid,oracletx,hashBlock) != 0 && (numvouts=oracletx.vout.size()) > 0 )
@@ -1121,15 +1122,13 @@ UniValue OracleDataSamples(uint256 reforacletxid,char* batonaddr,int32_t num)
break; break;
} }
} }
SetCCtxids(addressIndex,batonaddr,true); SetCCtxids(txids,batonaddr,true,EVAL_ORACLES,reforacletxid,'D');
if (addressIndex.size()>0) if (txids.size()>0)
{ {
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.end()-1; it!=addressIndex.begin(); it--) for (std::vector<uint256>::const_iterator it=txids.end()-1; it!=txids.begin(); it--)
{ {
txid=it->first.txhash; txid=*it;
vout = (int32_t)it->first.index; if (myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size()) > 0 )
nValue = (int64_t)it->second;
if (vout==1 && nValue==10000 && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size()) > 0 )
{ {
if ( DecodeOraclesData(tx.vout[numvouts-1].scriptPubKey,oracletxid,btxid,pk,data) == 'D' && reforacletxid == oracletxid ) if ( DecodeOraclesData(tx.vout[numvouts-1].scriptPubKey,oracletxid,btxid,pk,data) == 'D' && reforacletxid == oracletxid )
{ {
@@ -1223,12 +1222,12 @@ UniValue OracleInfo(uint256 origtxid)
UniValue OraclesList() UniValue OraclesList()
{ {
UniValue result(UniValue::VARR); std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock; CTransaction createtx; std::string name,description,format; char str[65]; UniValue result(UniValue::VARR); std::vector<uint256> txids; struct CCcontract_info *cp,C; uint256 txid,hashBlock; CTransaction createtx; std::string name,description,format; char str[65];
cp = CCinit(&C,EVAL_ORACLES); cp = CCinit(&C,EVAL_ORACLES);
SetCCtxids(addressIndex,cp->normaladdr,false); SetCCtxids(txids,cp->normaladdr,false,cp->evalcode,zeroid,'C');
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) for (std::vector<uint256>::const_iterator it=txids.begin(); it!=txids.end(); it++)
{ {
txid = it->first.txhash; txid = *it;
if ( myGetTransaction(txid,createtx,hashBlock) != 0 ) if ( myGetTransaction(txid,createtx,hashBlock) != 0 )
{ {
if ( createtx.vout.size() > 0 && DecodeOraclesCreateOpRet(createtx.vout[createtx.vout.size()-1].scriptPubKey,name,description,format) == 'C' ) if ( createtx.vout.size() > 0 && DecodeOraclesCreateOpRet(createtx.vout[createtx.vout.size()-1].scriptPubKey,name,description,format) == 'C' )

View File

@@ -77,6 +77,18 @@
// start of consensus code // start of consensus code
void mpz_set_lli( mpz_t rop, long long op )
{
mpz_import(rop, 1, 1, sizeof(op), 0, 0, &op);
}
int64_t mpz_get_si2( mpz_t op )
{
int64_t ret = 0;
mpz_export(&ret, NULL, 1, sizeof(ret), 0, 0, op);
return ret;
}
CScript EncodePaymentsTxidOpRet(int64_t allocation,std::vector<uint8_t> scriptPubKey,std::vector<uint8_t> destopret) CScript EncodePaymentsTxidOpRet(int64_t allocation,std::vector<uint8_t> scriptPubKey,std::vector<uint8_t> destopret)
{ {
CScript opret; uint8_t evalcode = EVAL_PAYMENTS; CScript opret; uint8_t evalcode = EVAL_PAYMENTS;
@@ -277,7 +289,7 @@ int32_t payments_getallocations(int32_t top, int32_t bottom, const std::vector<s
//fprintf(stderr, "address: %s nValue.%li \n", CBitcoinAddress(address.second).ToString().c_str(), address.first); //fprintf(stderr, "address: %s nValue.%li \n", CBitcoinAddress(address.second).ToString().c_str(), address.first);
scriptPubKeys.push_back(scriptPubKey); scriptPubKeys.push_back(scriptPubKey);
allocations.push_back(address.first); allocations.push_back(address.first);
mpz_set_si(mpzAllocation,address.first); mpz_set_lli(mpzAllocation,address.first);
mpz_add(mpzTotalAllocations,mpzTotalAllocations,mpzAllocation); mpz_add(mpzTotalAllocations,mpzTotalAllocations,mpzAllocation);
mpz_clear(mpzAllocation); mpz_clear(mpzAllocation);
} }
@@ -316,7 +328,7 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &
return(eval->Invalid("could not decode ccopret")); return(eval->Invalid("could not decode ccopret"));
if ( tx.vout.back().scriptPubKey.IsOpReturn() ) if ( tx.vout.back().scriptPubKey.IsOpReturn() )
fHasOpret = true; fHasOpret = true;
mpz_set_si(mpzCheckamount,amountReleased); mpz_set_lli(mpzCheckamount,amountReleased);
} else return(eval->Invalid("could not decode ccopret")); } else return(eval->Invalid("could not decode ccopret"));
// use the createtxid to fetch the tx and all of the plans info. // use the createtxid to fetch the tx and all of the plans info.
@@ -382,7 +394,7 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &
//fprintf(stderr, "totalallocations.%li checkallocations.%li\n",totalallocations, checkallocations); //fprintf(stderr, "totalallocations.%li checkallocations.%li\n",totalallocations, checkallocations);
if ( totalallocations != checkallocations ) if ( totalallocations != checkallocations )
return(eval->Invalid("allocation missmatch")); return(eval->Invalid("allocation missmatch"));
mpz_set_si(mpzTotalAllocations,totalallocations); mpz_set_lli(mpzTotalAllocations,totalallocations);
} }
else if ( funcid == 'S' || funcid == 'O' ) else if ( funcid == 'S' || funcid == 'O' )
{ {
@@ -438,16 +450,16 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &
else else
{ {
mpz_init(mpzAllocation); mpz_init(mpzAllocation);
mpz_set_si(mpzAllocation,allocations[n]); mpz_set_lli(mpzAllocation,allocations[n]);
mpz_mul(mpzAllocation,mpzAllocation,mpzCheckamount); mpz_mul(mpzAllocation,mpzAllocation,mpzCheckamount);
mpz_tdiv_q(mpzAllocation,mpzAllocation,mpzTotalAllocations); mpz_tdiv_q(mpzAllocation,mpzAllocation,mpzTotalAllocations);
test = mpz_get_si(mpzAllocation); test = mpz_get_si2(mpzAllocation);
mpz_clear(mpzAllocation); mpz_clear(mpzAllocation);
} }
//fprintf(stderr, "vout %i test.%li nValue.%li\n", i, test, tx.vout[i].nValue); //fprintf(stderr, "vout.%i test.%lli vs nVlaue.%lli\n",i, (long long)test, (long long)tx.vout[i].nValue);
if ( test != tx.vout[i].nValue ) if ( test != tx.vout[i].nValue )
{ {
fprintf(stderr, "vout.%i test.%li vs nVlaue.%li\n",i, test, tx.vout[i].nValue); fprintf(stderr, "vout.%i test.%lli vs nVlaue.%lli\n",i, (long long)test, (long long)tx.vout[i].nValue);
return(eval->Invalid("amounts do not match")); return(eval->Invalid("amounts do not match"));
} }
if ( test < minimum ) if ( test < minimum )
@@ -463,10 +475,10 @@ bool PaymentsValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &
{ {
// need to check that the next allocation was less than minimum, otherwise ppl can truncate the tx at any place not paying all elegible addresses. // need to check that the next allocation was less than minimum, otherwise ppl can truncate the tx at any place not paying all elegible addresses.
mpz_init(mpzAllocation); mpz_init(mpzAllocation);
mpz_set_si(mpzAllocation,allocations[n+1]); mpz_set_lli(mpzAllocation,allocations[n+1]);
mpz_mul(mpzAllocation,mpzAllocation,mpzCheckamount); mpz_mul(mpzAllocation,mpzAllocation,mpzCheckamount);
mpz_tdiv_q(mpzAllocation,mpzAllocation,mpzTotalAllocations); mpz_tdiv_q(mpzAllocation,mpzAllocation,mpzTotalAllocations);
int64_t test = mpz_get_si(mpzAllocation); int64_t test = mpz_get_si2(mpzAllocation);
//fprintf(stderr, "check next vout pays under min: test.%li > minimuim.%i\n", test, minimum); //fprintf(stderr, "check next vout pays under min: test.%li > minimuim.%i\n", test, minimum);
if ( test > minimum ) if ( test > minimum )
return(eval->Invalid("next allocation was not under minimum")); return(eval->Invalid("next allocation was not under minimum"));
@@ -785,7 +797,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr)
return(result); return(result);
} }
// set totalallocations to a mpz_t bignum, for amounts calculation later. // set totalallocations to a mpz_t bignum, for amounts calculation later.
mpz_set_si(mpzTotalAllocations,totalallocations); mpz_set_lli(mpzTotalAllocations,totalallocations);
} }
else if ( funcid == 'S' || funcid == 'O' ) else if ( funcid == 'S' || funcid == 'O' )
{ {
@@ -852,7 +864,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr)
} }
newamount = amount; newamount = amount;
int64_t totalamountsent = 0; int64_t totalamountsent = 0;
mpz_t mpzAmount; mpz_init(mpzAmount); mpz_set_si(mpzAmount,amount); mpz_t mpzAmount; mpz_init(mpzAmount); mpz_set_lli(mpzAmount,amount);
for (i=0; i<m; i++) for (i=0; i<m; i++)
{ {
mpz_t mpzValue; mpz_init(mpzValue); mpz_t mpzValue; mpz_init(mpzValue);
@@ -860,11 +872,11 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr)
mtx.vout[i+1].nValue = amount / (top-bottom); mtx.vout[i+1].nValue = amount / (top-bottom);
else else
{ {
mpz_set_si(mpzValue,mtx.vout[i+1].nValue); mpz_set_lli(mpzValue,mtx.vout[i+1].nValue);
mpz_mul(mpzValue,mpzValue,mpzAmount); mpz_mul(mpzValue,mpzValue,mpzAmount);
mpz_tdiv_q(mpzValue,mpzValue,mpzTotalAllocations); mpz_tdiv_q(mpzValue,mpzValue,mpzTotalAllocations);
if ( mpz_fits_slong_p(mpzValue) ) if ( mpz_fits_slong_p(mpzValue) )
mtx.vout[i+1].nValue = mpz_get_si(mpzValue); mtx.vout[i+1].nValue = mpz_get_si2(mpzValue);
else else
{ {
result.push_back(Pair("result","error")); result.push_back(Pair("result","error"));
@@ -897,7 +909,7 @@ UniValue PaymentsRelease(struct CCcontract_info *cp,char *jsonstr)
totalamountsent += mtx.vout[i+1].nValue; totalamountsent += mtx.vout[i+1].nValue;
} }
if ( totalamountsent < amount ) newamount = totalamountsent; if ( totalamountsent < amount ) newamount = totalamountsent;
//int64_t temptst = mpz_get_si(mpzTotalAllocations); //int64_t temptst = mpz_get_si2(mpzTotalAllocations);
//fprintf(stderr, "checkamount RPC.%li totalallocations.%li\n",totalamountsent, temptst); //fprintf(stderr, "checkamount RPC.%li totalallocations.%li\n",totalamountsent, temptst);
mpz_clear(mpzAmount); mpz_clear(mpzTotalAllocations); mpz_clear(mpzAmount); mpz_clear(mpzTotalAllocations);
} }

View File

@@ -1225,7 +1225,7 @@ UniValue PegsAccountHistory(uint256 pegstxid)
{ {
char coinaddr[64]; int64_t nValue,amount; uint256 txid,accounttxid,hashBlock,tmptokenid,tmppegstxid; char coinaddr[64]; int64_t nValue,amount; uint256 txid,accounttxid,hashBlock,tmptokenid,tmppegstxid;
CTransaction tx; int32_t numvouts,vout; char funcid; CPubKey mypk,pegspk,pk; std::map<uint256,std::pair<int64_t,int64_t>> accounts; CTransaction tx; int32_t numvouts,vout; char funcid; CPubKey mypk,pegspk,pk; std::map<uint256,std::pair<int64_t,int64_t>> accounts;
std::vector<std::pair<CAddressIndexKey, CAmount> > txids; std::pair<int64_t,int64_t> account; std::vector<uint256> txids; std::pair<int64_t,int64_t> account;
UniValue result(UniValue::VOBJ),acc(UniValue::VARR); struct CCcontract_info *cp,C; UniValue result(UniValue::VOBJ),acc(UniValue::VARR); struct CCcontract_info *cp,C;
result.push_back(Pair("result","success")); result.push_back(Pair("result","success"));
@@ -1234,13 +1234,11 @@ UniValue PegsAccountHistory(uint256 pegstxid)
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
pegspk = GetUnspendable(cp,0); pegspk = GetUnspendable(cp,0);
GetCCaddress1of2(cp,coinaddr,mypk,pegspk); GetCCaddress1of2(cp,coinaddr,mypk,pegspk);
SetCCtxids(txids,coinaddr,true); SetCCtxids(txids,coinaddr,true,EVAL_PEGS,pegstxid,0);
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=txids.begin(); it!=txids.end(); it++) for (std::vector<uint256>::const_iterator it=txids.begin(); it!=txids.end(); it++)
{ {
txid = it->first.txhash; txid = *it;
vout = (int32_t)it->first.index; if (myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size())>0 &&
nValue = (int64_t)it->second;
if (vout == 1 && nValue == CC_MARKER_VALUE && myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts=tx.vout.size())>0 &&
(funcid=DecodePegsOpRet(tx,tmppegstxid,tmptokenid))!=0 && pegstxid==tmppegstxid) (funcid=DecodePegsOpRet(tx,tmppegstxid,tmptokenid))!=0 && pegstxid==tmppegstxid)
{ {
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);

View File

@@ -432,13 +432,13 @@ int64_t RewardsPlanFunds(uint64_t &lockedfunds,uint64_t refsbits,struct CCcontra
bool RewardsPlanExists(struct CCcontract_info *cp,uint64_t refsbits,CPubKey rewardspk,uint64_t &APR,uint64_t &minseconds,uint64_t &maxseconds,uint64_t &mindeposit) bool RewardsPlanExists(struct CCcontract_info *cp,uint64_t refsbits,CPubKey rewardspk,uint64_t &APR,uint64_t &minseconds,uint64_t &maxseconds,uint64_t &mindeposit)
{ {
char CCaddr[64]; uint64_t sbits; uint256 txid,hashBlock; CTransaction tx; char CCaddr[64]; uint64_t sbits; uint256 txid,hashBlock; CTransaction tx;
std::vector<std::pair<CAddressIndexKey, CAmount> > txids; std::vector<uint256> txids;
GetCCaddress(cp,CCaddr,rewardspk); GetCCaddress(cp,CCaddr,rewardspk);
SetCCtxids(txids,CCaddr,true); SetCCtxids(txids,CCaddr,true,cp->evalcode,zeroid,'F');
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=txids.begin(); it!=txids.end(); it++) for (std::vector<uint256>::const_iterator it=txids.begin(); it!=txids.end(); it++)
{ {
//int height = it->first.blockHeight; //int height = it->first.blockHeight;
txid = it->first.txhash; txid = *it;
if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout.size() > 0 && ConstrainVout(tx.vout[0],1,CCaddr,0) != 0 ) if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout.size() > 0 && ConstrainVout(tx.vout[0],1,CCaddr,0) != 0 )
{ {
//char str[65]; fprintf(stderr,"rewards plan %s\n",uint256_str(str,txid)); //char str[65]; fprintf(stderr,"rewards plan %s\n",uint256_str(str,txid));
@@ -492,12 +492,12 @@ UniValue RewardsInfo(uint256 rewardsid)
UniValue RewardsList() UniValue RewardsList()
{ {
UniValue result(UniValue::VARR); std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock; CTransaction vintx; uint64_t sbits,APR,minseconds,maxseconds,mindeposit; char str[65]; UniValue result(UniValue::VARR); std::vector<uint256> txids; struct CCcontract_info *cp,C; uint256 txid,hashBlock; CTransaction vintx; uint64_t sbits,APR,minseconds,maxseconds,mindeposit; char str[65];
cp = CCinit(&C,EVAL_REWARDS); cp = CCinit(&C,EVAL_REWARDS);
SetCCtxids(addressIndex,cp->normaladdr,false); SetCCtxids(txids,cp->normaladdr,false,cp->evalcode,zeroid,'F');
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) for (std::vector<uint256>::const_iterator it=txids.begin(); it!=txids.end(); it++)
{ {
txid = it->first.txhash; txid = *it;
if ( myGetTransaction(txid,vintx,hashBlock) != 0 ) if ( myGetTransaction(txid,vintx,hashBlock) != 0 )
{ {
if ( vintx.vout.size() > 0 && DecodeRewardsFundingOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,sbits,APR,minseconds,maxseconds,mindeposit) != 0 ) if ( vintx.vout.size() > 0 && DecodeRewardsFundingOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,sbits,APR,minseconds,maxseconds,mindeposit) != 0 )

View File

@@ -1452,15 +1452,15 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params)
{ {
UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); uint256 txid,hashBlock,gametxid,tokenid,playertxid; int32_t vout,maxplayers,gameheight,numvouts; CPubKey roguepk,mypk; char coinaddr[64]; CTransaction tx,gametx; int64_t buyin; UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); uint256 txid,hashBlock,gametxid,tokenid,playertxid; int32_t vout,maxplayers,gameheight,numvouts; CPubKey roguepk,mypk; char coinaddr[64]; CTransaction tx,gametx; int64_t buyin;
std::vector<std::pair<CAddressIndexKey, CAmount> > addressIndex; std::vector<uint256> txids;
//std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs; //std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
roguepk = GetUnspendable(cp,0); roguepk = GetUnspendable(cp,0);
mypk = pubkey2pk(Mypubkey()); mypk = pubkey2pk(Mypubkey());
GetCCaddress1of2(cp,coinaddr,roguepk,mypk); GetCCaddress1of2(cp,coinaddr,roguepk,mypk);
//SetCCunspents(unspentOutputs,coinaddr); //SetCCunspents(unspentOutputs,coinaddr);
SetCCtxids(addressIndex,coinaddr,true); SetCCtxids(txids,coinaddr,true,cp->evalcode,zeroid,'R');
rogue_univalue(result,"games",-1,-1); rogue_univalue(result,"games",-1,-1);
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) for (std::vector<uint256>::const_iterator it=txids.begin(); it!=txids.end(); it++)
//for (std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) //for (std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++)
{ {
txid = it->first.txhash; txid = it->first.txhash;

View File

@@ -89,7 +89,7 @@ static CBlock CreateGenesisBlock(uint32_t nTime, const uint256& nNonce, const st
* timestamp before) * timestamp before)
* + Contains no strange transactions * + Contains no strange transactions
*/ */
void *chainparams_commandline(void *ptr); void *chainparams_commandline();
#include "komodo_defs.h" #include "komodo_defs.h"
int32_t ASSETCHAINS_BLOCKTIME = 60; int32_t ASSETCHAINS_BLOCKTIME = 60;
uint64_t ASSETCHAINS_NK[2]; uint64_t ASSETCHAINS_NK[2];
@@ -214,11 +214,6 @@ public:
fRequireStandard = true; fRequireStandard = true;
fMineBlocksOnDemand = false; fMineBlocksOnDemand = false;
fTestnetToBeDeprecatedFieldRPC = false; fTestnetToBeDeprecatedFieldRPC = false;
if ( pthread_create((pthread_t *)malloc(sizeof(pthread_t)),NULL,chainparams_commandline,(void *)&consensus) != 0 )
{
}
} }
}; };
@@ -247,290 +242,6 @@ void CChainParams::SetCheckpointData(CChainParams::CCheckpointData checkpointDat
*/ */
int32_t MAX_BLOCK_SIZE(int32_t height)
{
int32_t saplinght = mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight;
//fprintf(stderr,"MAX_BLOCK_SIZE %d vs. %d\n",height,mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight);
if ( height <= 0 || (saplinght > 0 && height >= saplinght) )
{
return(_MAX_BLOCK_SIZE);
}
else return(2000000);
}
void komodo_setactivation(int32_t height)
{
mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight = height;
mainParams.consensus.vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight = height;
ASSETCHAINS_SAPLING = height;
fprintf(stderr,"SET SAPLING ACTIVATION height.%d\n",height);
}
void *chainparams_commandline(void *ptr)
{
CChainParams::CCheckpointData checkpointData;
while ( ASSETCHAINS_P2PPORT == 0 )
{
#ifdef _WIN32
boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
#else
sleep(1);
#endif
}
//fprintf(stderr,">>>>>>>> port.%u\n",ASSETCHAINS_P2PPORT);
if ( ASSETCHAINS_SYMBOL[0] != 0 )
{
if ( ASSETCHAINS_BLOCKTIME != 60 )
{
mainParams.consensus.nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME; // 7 blocks
mainParams.consensus.nPowTargetSpacing = ASSETCHAINS_BLOCKTIME;
}
mainParams.SetDefaultPort(ASSETCHAINS_P2PPORT);
if ( ASSETCHAINS_NK[0] != 0 && ASSETCHAINS_NK[1] != 0 )
{
//BOOST_STATIC_ASSERT(equihash_parameters_acceptable(ASSETCHAINS_NK[0], ASSETCHAINS_NK[1]));
mainParams.SetNValue(ASSETCHAINS_NK[0]);
mainParams.SetKValue(ASSETCHAINS_NK[1]);
}
if ( KOMODO_TESTNODE != 0 )
mainParams.SetMiningRequiresPeers(false);
if ( ASSETCHAINS_RPCPORT == 0 )
ASSETCHAINS_RPCPORT = ASSETCHAINS_P2PPORT + 1;
mainParams.pchMessageStart[0] = ASSETCHAINS_MAGIC & 0xff;
mainParams.pchMessageStart[1] = (ASSETCHAINS_MAGIC >> 8) & 0xff;
mainParams.pchMessageStart[2] = (ASSETCHAINS_MAGIC >> 16) & 0xff;
mainParams.pchMessageStart[3] = (ASSETCHAINS_MAGIC >> 24) & 0xff;
fprintf(stderr,">>>>>>>>>> %s: p2p.%u rpc.%u magic.%08x %u %u coins\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,ASSETCHAINS_MAGIC,ASSETCHAINS_MAGIC,(uint32_t)ASSETCHAINS_SUPPLY);
if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH)
{
// this is only good for 60 second blocks with an averaging window of 45. for other parameters, use:
// nLwmaAjustedWeight = (N+1)/2 * (0.9989^(500/nPowAveragingWindow)) * nPowTargetSpacing
mainParams.consensus.nLwmaAjustedWeight = 1350;
mainParams.consensus.nPowAveragingWindow = 45;
mainParams.consensus.powAlternate = uint256S("00000f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f");
}
else if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV1_1)
{
// this is only good for 60 second blocks with an averaging window of 45. for other parameters, use:
// nLwmaAjustedWeight = (N+1)/2 * (0.9989^(500/nPowAveragingWindow)) * nPowTargetSpacing
mainParams.consensus.nLwmaAjustedWeight = 1350;
mainParams.consensus.nPowAveragingWindow = 45;
mainParams.consensus.powAlternate = uint256S("0000000f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f");
}
if (ASSETCHAINS_LWMAPOS != 0)
{
mainParams.consensus.posLimit = uint256S("000000000f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f");
mainParams.consensus.nPOSAveragingWindow = 45;
// spacing is 1000 units per block to get better resolution, POS is 50% hard coded for now, we can vary it later
// when we get reliable integer math on nLwmaPOSAjustedWeight
mainParams.consensus.nPOSTargetSpacing = VERUS_BLOCK_POSUNITS * 2;
// nLwmaPOSAjustedWeight = (N+1)/2 * (0.9989^(500/nPOSAveragingWindow)) * nPOSTargetSpacing
// this needs to be recalculated if VERUS_BLOCK_POSUNITS is changed
mainParams.consensus.nLwmaPOSAjustedWeight = 46531;
}
// only require coinbase protection on Verus from the Komodo family of coins
if (strcmp(ASSETCHAINS_SYMBOL,"VRSC") == 0)
{
mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight = 227520;
mainParams.consensus.vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight = 227520;
mainParams.consensus.fCoinbaseMustBeProtected = true;
checkpointData = //(Checkpoints::CCheckpointData)
{
boost::assign::map_list_of
(0, mainParams.consensus.hashGenesisBlock)
(10000, uint256S("0xac2cd7d37177140ea4991cf630c0b9c7f94d707b84fb0351bf3a44856d2ae5dc"))
(20000, uint256S("0xb0e8cb9f77aaa7ff5bd90d6c08d06f4c4bf03e00c2b8a35a042e760845590c8a"))
(30000, uint256S("0xf2112ca577338ad7104bf905fa6a63d36b17a86f914c97b73cd31d43fcd7557c"))
(40000, uint256S("0x00000000008f83378dab727864b763ce91a4ea5f75d55939c0c1390cfb8c38f1"))
(49170, uint256S("0x2add646c0089871ec2379f02f7cd60b3af6efd9c152a6f16fc10925458c270cc")),
(int64_t)1529910234, // * UNIX timestamp of last checkpoint block
(int64_t)63661, // * total number of transactions between genesis and last checkpoint
// (the tx=... number in the SetBestChain debug.log lines)
(double)2777 // * estimated number of transactions per day after checkpoint
// total number of tx / (checkpoint block height / (24 * 24))
};
mainParams.consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000000000001a8f4f23f8b2d1f7e");
}
else
{
if (strcmp(ASSETCHAINS_SYMBOL,"VRSCTEST") == 0 || strcmp(ASSETCHAINS_SYMBOL,"VERUSTEST") == 0)
{
mainParams.consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000000000000000000001f7e");
}
mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight = ASSETCHAINS_SAPLING;
mainParams.consensus.vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight = ASSETCHAINS_OVERWINTER;
checkpointData = //(Checkpoints::CCheckpointData)
{
boost::assign::map_list_of
(0, mainParams.consensus.hashGenesisBlock),
(int64_t)1231006505,
(int64_t)1,
(double)2777 // * estimated number of transactions per day after checkpoint
// total number of tx / (checkpoint block height / (24 * 24))
};
}
}
else
{
checkpointData = //(Checkpoints::CCheckpointData)
{
boost::assign::map_list_of
(0, mainParams.consensus.hashGenesisBlock)
( 5000, uint256S("0x049cfc91eef411e96603a42c9a77c5e30e9fe96f783ab818f4c00fb56fb29b6c"))
( 10000, uint256S("0x0a0169db3614311cd4181deb73cfcf7f640e7dc956cda34e0121a0351925e9ae"))
( 15000, uint256S("0x00f0bd236790e903321a2d22f85bd6bf8a505f6ef4eddb20458a65d37e14d142"))
( 20000, uint256S("0x01bbf0c38892bdcced62b538329cf63bc7badca3e7e1bff8eb10345436871c6e"))
( 25000, uint256S("0x04ca27808268dda8f942b647a6df844be1b263a661a13740293db962022d1f9e"))
( 30000, uint256S("0x04c9e8cfbcd37399085e529b50147de8afb80c76c48752c122d56f23316a7acb"))
( 35000, uint256S("0x00815f1240354cff7487c67f7dff78e248cb9053ed2c92751d1a9ad42d3eaedf"))
( 40000, uint256S("0x00eafd9dfb1e5f1bf1cca0c49be628538900daf69b665464443d29c2c3b6a2fe"))
( 45000, uint256S("0x0377730632caf694b92f40d03ae0fbe5bd86a1205014b71d975453ac793b0af9"))
( 50000, uint256S("0x00076e16d3fa5194da559c17cf9cf285e21d1f13154ae4f7c7b87919549345aa"))
( 55000, uint256S("0x0005a0701a83e05b639418ea4c87018544a4d22b2b49e5f111161e8ffc455108"))
( 60000, uint256S("0x0000296fc15f8599b7c6561d0e0a96f24766135ed79107b603d6dd6e55142c0d"))
( 65000, uint256S("0x000861f5d7970d5399733b4605074d47f877d6536f74ffae6f08e871ee29e6f2"))
( 70000, uint256S("0x0002af1d487c567526c517b52996944dca344e139cddca77c2e72f746e73b263"))
( 75000, uint256S("0x0d08129659be5f105e70c047769359eaf3475d61a726750859fdca3e1a2bf5cc"))
( 80000, uint256S("0x0af5f3f1caae4f08c74a82689731d1ef8e55107c06f9a996e251b8ecb96989ad"))
( 85000, uint256S("0x00000c8ee29086c5fb39eddad0619773b9ce936c77c13e5e5118a4998e939544"))
( 90000, uint256S("0x06d3bb7f9ee5b55f67b2dc13c680699a2f736f43a44b4e4cfd41a58aa00f063f"))
( 95000, uint256S("0x0670981b269879aae83a88f6f0c4db34763c93fd410d96435f2acb4e6580b976"))
( 100000, uint256S("0x0f02eb1f3a4b89df9909fec81a4bd7d023e32e24e1f5262d9fc2cc36a715be6f"))
( 105000, uint256S("0x018b97d7e6d259add24afe0e08fc125dc21d734e8831b68b430f5c3896deb4af"))
( 110000, uint256S("0x09644ff52734e0e911a9ba7ecd03cf7995b25301840a9637891ef9af69f59c32"))
( 115000, uint256S("0x0ee382b4729b8ceb918a92913f9c144a6a4f8a50bfc0f8b4aac5b12592caed7f"))
( 120000, uint256S("0x082a7918a0dd9cb2df65f55acb8d0a4a535b3fa684d92c3ebcb24ed7019d975b"))
( 125000, uint256S("0x00008f76c4484fd539c9d02fc69c40a50b6f9e00984d33890b85cc0324159e9e"))
( 130000, uint256S("0x011b09e53acfe46f310e8c960a9c4f4f490cc7b2cd3791d7a6a80d6e8ac96b36"))
( 135000, uint256S("0x01e0cd48358fa05646baa6f00e26717474d6049a537c8861b324d1f497dc3d4a"))
( 140000, uint256S("0x0e6db36fd8a9d1b7baf359c8bd5c76635d0bcada973a75b5d2028ca3baea4961"))
( 145000, uint256S("0x00010c40b57316ce6cde076807c9db956452a3c82cb09fe7d56c6bb1a7e24726"))
( 150000, uint256S("0x0a817f15b9da636f453a7a01835cfc534ed1a55ce7f08c566471d167678bedce"))
( 155000, uint256S("0x0528084fd00223bd9747635d7a4d8cc79f158795cad654efb78e4e4cc5f23d6a"))
( 160000, uint256S("0x00003a09f26ae9fb7ebbfa3ef589b81ccd8909a82430f7414bc68d5a5a3316ab"))
( 165000, uint256S("0x00004a0c6a29e7d1f22ea4e44d05e861fec5fcd8eebc5a61574c4ecf29dbb9be"))
( 170000, uint256S("0x0cf9eac27badc0ae9a2b370dd7cc3fcb550f139349551e60978f394a2e1b262b"))
( 175000, uint256S("0x0000137856b825d431da27ff4c3cf22f5482fa21952d45b0db0ec6774fb9b510"))
( 180000, uint256S("0x000000b0afcccf98aa0afb6ac61050892bd9415857d66313d1f67fd1bbac312f"))
( 185000, uint256S("0x00c2af8f88d84de080067f8ae1c25754e32e5516d20c11f85b9adae2d683687b"))
( 190000, uint256S("0x00000033d85b3e7d19e02278ef300b8ab957d3dd3e58b4c81166ba0a58af5c3f"))
( 195000, uint256S("0x000000964b6068be1dd4ee6893d183e86cba82a2744fb5439c463d0ba7e053b6"))
( 200000, uint256S("0x000001763a9337328651ca57ac487cc0507087be5838fb74ca4165ff19f0e84f"))
( 205000, uint256S("0x049fc6832e64a75ae898b32804e151e7561ea49082858c3d4af89a7de4b82f06"))
( 210000, uint256S("0x0000000d9078b9c9604cc663eafafba8f3643bb3f3ddbb78fed4993236e1edb5"))
( 215000, uint256S("0x00060089ecc21bcc62094e2f7f0448fe163415f6ef2f2aafe047757889ca82fe"))
( 220000, uint256S("0x000082c78e6c2a13a9c23dd7a6faaf962fc133142b4a2d07725561f59c03bfa2"))
( 225000, uint256S("0x00030026483167fe13505cf27049307ce42e0d9c5aa093aed10baa4f49edf4ca"))
( 230000, uint256S("0x000183a3e17988060a35776b99c1f0b43393bbe7153b2718dfc57f428191de4e"))
( 235000, uint256S("0x000184995f0ec024ed3783e322c8cfa5e68d9f0c77c3aaea301b22d311619156"))
( 240000, uint256S("0x0000002cc7cf6d0a44ab57f9bd3bfa11a865bbf1cd87a2081095bc90981633a3"))
( 245000, uint256S("0x004c5f19a88c8fe8a604006dbd2d44c94baef2a00876a17d8e2be2124003f979"))
( 250000, uint256S("0x0dd54ef5f816c7fde9d2b1c8c1a26412b3c761cc5dd3901fa5c4cd1900892fba"))
( 255000, uint256S("0x0b6da9e4f50c8bc7a92c539bc7474ffd6c29e0a8531f0dbbbc261fff1f990827"))
( 260000, uint256S("0x0cac8b12bf7233ee5a68fcde9e251852b177833fefa2a9f39ec28474b0851cb9"))
( 265000, uint256S("0x04feb5b4029f3b8b8eb3e6661a78eadd1a26b4af00ac59b5f05b261afcfd2818"))
( 270000, uint256S("0x01bc5897bd20b8b61acf4989987ba85fbc37d9ebe848924aa8effcb08bf48fe0"))
( 275000, uint256S("0x0416bc29eb5a12231826e546ba90fcd38aeef387ff77b45849cd418a9c1a6f12"))
( 280000, uint256S("0x000007593e9880b171d46bce59aa0cec2a1b1f53d1fd7e8f71ccb2b9182374a4"))
( 285000, uint256S("0x05a338b2d90cd79740221fe8635b7a834f2e486fcbb2464a4294f5a21231a5f5"))
( 290000, uint256S("0x064ca3912cdcd833702d07a530e98bc5c6c1cd738a8825c7240b17cd68ca0cc4"))
( 295000, uint256S("0x036b3bb318d743fd78db983a9aadd52869991d48913c4eebe2a074387d67cc5a"))
( 300000, uint256S("0x000000fa5efd1998959926047727519ed7de06dcf9f2cd92a4f71e907e1312dc"))
( 305000, uint256S("0x00003656231e83de2348755153ed175794696a113d7e8a15c01f90fdb7c2f287"))
( 310000, uint256S("0x0cf6baf727eb931da0813ed8b032648c4766be79e146b0d40c643f9d8edf40f7"))
( 315000, uint256S("0x082469974c152ebe69f1787f0d06aa5d9dd1dc69c880febde7eac2bc800146dd"))
( 320000, uint256S("0x0000063df36b99bfb2516f55cb548a5baed1f2d8ae69c3559dc478c5c2eb32df"))
( 325000, uint256S("0x0cb926b303a1514ba0a2f729af88ccb143517f396e9e0bde09b0736900698e0f"))
( 330000, uint256S("0x000000be3d8bb6e31c3b534819aae7014cbbe9a44ab3e799dc1bfc724c6ab184"))
( 335000, uint256S("0x0d0756608189fd5bbd8ec50e76180074e69e973439cc09df49134e4cb970ed4d"))
( 340000, uint256S("0x0d814eacdb9c97003d703c0ff79b1b97b9ed8615fe12b1afaede946e5fdfe0a7"))
( 345000, uint256S("0x000000c2910f510f1de325d300202da1a391f2719dd378173299151c3da94e85"))
( 350000, uint256S("0x0000000228ef321323f81dae00c98d7960fc7486fb2d881007fee60d1e34653f"))
( 355000, uint256S("0x03e6a55e382b478e0fab9c3584da3629fd9b977986a333a406b24b0d3559bf44"))
( 360000, uint256S("0x0859c86dd718bcb5b58af06389197794e2beea6239653f2e6fa7b8a7433d29ea"))
( 365000, uint256S("0x07896332665c707a8f55398a998e7878e8d2681ba79dd95c2859b1dafc9343d0"))
( 370000, uint256S("0x040efd8c64cf5cf96ecf75468741a8880d1386eb5e349bef0a55116d4023944c"))
( 375000, uint256S("0x053029e7599a09fe6c01203997d7ca738dd4c6d216a433695a0d514def1eccc0"))
( 380000, uint256S("0x0cae44e7a421c389b88a5a204d3e39779e93aeacaab1b693741bf279fd0c8acd"))
( 385000, uint256S("0x0b4032d2c799ba93644231ce57134dd24e13ec0dc267c1ed5912389691d2bd72"))
( 390000, uint256S("0x0afd0f166f33a881ef289af7ea7010d58c4bbd560dee10b561c79e1b8dfd0593"))
( 395000, uint256S("0x083774b88cf1b138d67c242d9b33c54f69d7e901b5e8144dc4a2303ab9927102"))
( 400000, uint256S("0x036d294c5be96f4c0efb28e652eb3968231e87204a823991a85c5fdab3c43ae6"))
( 405000, uint256S("0x0522e33bb2161fb1b33acef9a4a438fcf420dcae8a0b472e234d223d731c42b2"))
( 410000, uint256S("0x0361d06aa807c66b87befea8119a485341d1118b694c3dbb4c3cf0b85ac69e9b"))
( 415000, uint256S("0x072d5653d8673f64ef8b9c655f7b8021072070a072b799013ff6e96de99a59e6"))
( 420000, uint256S("0x013b693d66955be69d4501cb1d307ca323a5c8473e25866ae7e700cdce0c654f"))
( 425000, uint256S("0x0ef0c55af27c6971289a790dee2b2ec728fb9c6555ff9306c07f1083cf0fb4b5"))
( 430000, uint256S("0x0ccbeeaba28291e0316a9cf54c005097c61dc67ba6f32283406d6c83b828da00"))
( 435000, uint256S("0x020ed6b7fe1124400baba7feed463ba0c90e7e6903493fdc1a1a18c4a506055a"))
( 440000, uint256S("0x055aaadca1908abeedc831a3f9115aa31284fc223d010590caf7b612960b61a4"))
( 445000, uint256S("0x06d2327fa25ea7e2be742fc0e45fc4f9adb41811f21be0357f8543c5434df715"))
( 450000, uint256S("0x0906ef1e8dc194f1f03bd4ce1ac8c6992fd721ef2c5ccbf4871ec8cdbb456c18"))
( 455000, uint256S("0x0b8b92eec29eb20262dcf9916f0ca36d6abf0c39d321d3f480a5535cb978db71"))
( 460000, uint256S("0x0cb04591f69a255b1127aaff3bbd59eaa21a5d9cca999de197516c251895c536"))
( 465000, uint256S("0x029985ae78d8bb8fd170aeb3ab02ea76134ed0c19ae00211cc28a61fe5755b88"))
( 470000, uint256S("0x01a2f4b56f37b223e75572862ad1ba956ec179332f8cd40590d7253563c86ba8"))
( 475000, uint256S("0x0a34c6f9d4d9cb8c78c14b8041a7cc1874cfcbb22a34a5c068d1d6ff3ed9fdf0"))
( 480000, uint256S("0x0ebab25030179996ae25969f34f6a297c7ffce1994f9b4186082a47032a9a7dc"))
( 485000, uint256S("0x06a096e6bccf3b85537a30f95db6a414deacc0509bc84da264c2830df1a1d9b0"))
( 490000, uint256S("0x0af828930ef13405cb536b88a3d1d4e0d84dc79ee260402c56bfa86e261c74ff"))
( 495000, uint256S("0x09d44905bfd12849d3c2178b2ba882f8e9d6565b6e4d7a97c70a92bd6de7c5e6"))
( 500000, uint256S("0x0bebdb417f7a51fe0c36fcf94e2ed29895a9a862eaa61601272866a7ecd6391b"))
( 505000, uint256S("0x0c1609f4f3561baa1fc975877948af94d2107c88686a9821bc240016cc87d953"))
( 510000, uint256S("0x0cf9a5a4997b871e615e5e398627e45fa15b3e6970ae22b47bdd11b0f5fa0fa7"))
( 515000, uint256S("0x034171d4819e9961de13309743a32a179abede97d60ea64101dc04c97a1a0807"))
( 520000, uint256S("0x0648fa44d5bbc2cc04a782e083c11df64ac06185f0f8e11a7416625ebb6409a6"))
( 525000, uint256S("0x0000000ef17d63af3159e52cd351b6f000536ad88adc3a937bb747955fed58a2"))
( 530000, uint256S("0x08e3af153995ba09e50086b64145cf4cd57db6b29f16f06f28d80d7f6121cfad"))
( 535000, uint256S("0x02a0ffd00b51e2061b85de50a9223d9c84f4e357dc1046397bb9d7d4a827a3fb"))
( 540000, uint256S("0x04bf07d026af29025c1ac2815e067f4a41d2872701ac9780eb3015d51cdcd854"))
( 545000, uint256S("0x0a0d6d86635946792ad0dca57ed227a5360fc8b6d79e47132aac11e90a4963ce"))
( 550000, uint256S("0x06df52fc5f9ba03ccc3a7673b01ab47990bd5c4947f6e1bc0ba14d21cd5bcccd"))
( 555000, uint256S("0x0baf38eea8e08fcad3a9d760f27377e79c291b08e7fb4920cadd5cb7bab547f3"))
( 560000, uint256S("0x00000004c34abbf1366adbae965b644c01debf15409acc715ff51cb221d92dd7"))
( 565000, uint256S("0x067bae7119f083e0fa1820bc8e25dcfa7717e42aabaef18beefd87d974953dfb"))
( 570000, uint256S("0x00000011a7ce7b628b7be17777d8dea2574d83f165e23c9e44aa705975820fd3"))
( 575000, uint256S("0x0e1110a193a30d3f8d369017233a2486b11c748b3d033859a2eb7b37062d303e"))
( 580000, uint256S("0x083cb58484aff80f48e3537e0451d49e544b3efa3da97274800c91e567d33a92"))
( 585000, uint256S("0x0224cf835428d03472edf4f7b6fcc63b9d8d6f1d5a90ad8186bf123d541b4ea8"))
( 590000, uint256S("0x0cfcf3b9517894e4df49db5faf8b74f3a9e01eb83c0cc5051c115d4424615dae"))
( 595000, uint256S("0x0000000a45266983dd81e0df381a3b0455699b2f76d5b4d3f17b87d657a1b56d"))
( 600000, uint256S("0x00000005080d5689c3b4466e551cd1986e5d2024a62a79b1335afe12c42779e4"))
( 605000, uint256S("0x0000001c691da36848542299af859d4eb3fa408a0f425b1fbe6d622d2100623a"))
( 610000, uint256S("0x040d8c7a0ac89e3ed8605a198583a795986aacbf18722a9897d7b925bcf757f6"))
( 615000, uint256S("0x0449cf00fc36206389c14cbf1d762f8b96bb0440ccea5b46703e7c69b0e2bc42"))
( 620000, uint256S("0x07227a41340c25ee1a7e9b60414259780202ffa990079fc91d8faeac9af03e60"))
( 625000, uint256S("0x047c2472fe2afabb3d38decf24bba4ba712b60e7a1782f4afae3ede3f912f493"))
( 630000, uint256S("0x0a7f1f04e66260cf972ab1374a9126b8abc1adaa3ab4669db5d4d4ddb9ad493d"))
( 635000, uint256S("0x048df95165eb821dabf37ef28cf7f3be72e216e95377684253dab806985b50a4"))
( 640000, uint256S("0x066b3c6a6a3c8dc58bef509a972c3e3ade14493b40e1b361ecbc928134e302be"))
( 645000, uint256S("0x07d059888c9ade3bbe16d6b4d70ee9b8302d104b37a3c6cd61f81012aabd0e1e"))
( 650000, uint256S("0x039a3cb760cc6e564974caf69e8ae621c14567f3a36e4991f77fd869294b1d52"))
( 655000, uint256S("0x089350ee8d28b44837eb4b1fe77704953d5de2077f10c74a888d9d3ea1e13c2a"))
( 660000, uint256S("0x000000023f8a582a61ae2f6fab6fe8197e79b7a68aaac67432421b09f1bdd4ba"))
( 665000, uint256S("0x0b16edce865e7a0d662115774e0c0d3abbf9c69004155b693ddc933f051bfb26"))
( 670000, uint256S("0x09070b109b089490bc372fd8358abae352d6db0e46ade6ed2200e4d4ff7aa6af"))
( 675000, uint256S("0x08d9edeed3b6ac55991e9f32af0218ff8fa9dc808078623f4c831eb09d4f186b"))
( 680000, uint256S("0x00000003eb2b30bfac929d3496acecab19625ac9f854a86aaf9678bea99e1cc1"))
( 681777, uint256S("0x0000243296b9b26c040f471fdd9398ef72e57062cf05c19b9ba2fefac8165306")),
(int64_t)1516924927, // * UNIX timestamp of last checkpoint block
(int64_t)1253783, // * total number of transactions between genesis and last checkpoint
// (the tx=... number in the SetBestChain debug.log lines)
(double)2777 // * estimated number of transactions per day after checkpoint
// total number of tx / (checkpoint block height / (24 * 24))
};
}
mainParams.SetCheckpointData(checkpointData);
ASSETCHAIN_INIT = 1;
return(0);
}
/** /**
* Testnet (v3) * Testnet (v3)
*/ */
@@ -826,3 +537,280 @@ void UpdateNetworkUpgradeParameters(Consensus::UpgradeIndex idx, int nActivation
{ {
regTestParams.UpdateNetworkUpgradeParameters(idx, nActivationHeight); regTestParams.UpdateNetworkUpgradeParameters(idx, nActivationHeight);
} }
int32_t MAX_BLOCK_SIZE(int32_t height)
{
int32_t saplinght = pCurrentParams->consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight;
//fprintf(stderr,"MAX_BLOCK_SIZE %d vs. %d\n",height,mainParams.consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight);
if ( height <= 0 || (saplinght > 0 && height >= saplinght) )
{
return(_MAX_BLOCK_SIZE);
}
else return(2000000);
}
void komodo_setactivation(int32_t height)
{
pCurrentParams->consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight = height;
pCurrentParams->consensus.vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight = height;
ASSETCHAINS_SAPLING = height;
fprintf(stderr,"SET SAPLING ACTIVATION height.%d\n",height);
}
void *chainparams_commandline()
{
fprintf(stderr,"chainparams_commandline called\n");
CChainParams::CCheckpointData checkpointData;
//fprintf(stderr,">>>>>>>> port.%u\n",ASSETCHAINS_P2PPORT);
if ( ASSETCHAINS_SYMBOL[0] != 0 )
{
if ( ASSETCHAINS_BLOCKTIME != 60 )
{
pCurrentParams->consensus.nMaxFutureBlockTime = 7 * ASSETCHAINS_BLOCKTIME; // 7 blocks
pCurrentParams->consensus.nPowTargetSpacing = ASSETCHAINS_BLOCKTIME;
}
pCurrentParams->SetDefaultPort(ASSETCHAINS_P2PPORT);
if ( ASSETCHAINS_NK[0] != 0 && ASSETCHAINS_NK[1] != 0 )
{
//BOOST_STATIC_ASSERT(equihash_parameters_acceptable(ASSETCHAINS_NK[0], ASSETCHAINS_NK[1]));
pCurrentParams->SetNValue(ASSETCHAINS_NK[0]);
pCurrentParams->SetKValue(ASSETCHAINS_NK[1]);
}
if ( KOMODO_TESTNODE != 0 )
pCurrentParams->SetMiningRequiresPeers(false);
if ( ASSETCHAINS_RPCPORT == 0 )
ASSETCHAINS_RPCPORT = ASSETCHAINS_P2PPORT + 1;
pCurrentParams->pchMessageStart[0] = ASSETCHAINS_MAGIC & 0xff;
pCurrentParams->pchMessageStart[1] = (ASSETCHAINS_MAGIC >> 8) & 0xff;
pCurrentParams->pchMessageStart[2] = (ASSETCHAINS_MAGIC >> 16) & 0xff;
pCurrentParams->pchMessageStart[3] = (ASSETCHAINS_MAGIC >> 24) & 0xff;
fprintf(stderr,">>>>>>>>>> %s: p2p.%u rpc.%u magic.%08x %u %u coins\n",ASSETCHAINS_SYMBOL,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,ASSETCHAINS_MAGIC,ASSETCHAINS_MAGIC,(uint32_t)ASSETCHAINS_SUPPLY);
if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASH)
{
// this is only good for 60 second blocks with an averaging window of 45. for other parameters, use:
// nLwmaAjustedWeight = (N+1)/2 * (0.9989^(500/nPowAveragingWindow)) * nPowTargetSpacing
pCurrentParams->consensus.nLwmaAjustedWeight = 1350;
pCurrentParams->consensus.nPowAveragingWindow = 45;
pCurrentParams->consensus.powAlternate = uint256S("00000f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f");
}
else if (ASSETCHAINS_ALGO == ASSETCHAINS_VERUSHASHV1_1)
{
// this is only good for 60 second blocks with an averaging window of 45. for other parameters, use:
// nLwmaAjustedWeight = (N+1)/2 * (0.9989^(500/nPowAveragingWindow)) * nPowTargetSpacing
pCurrentParams->consensus.nLwmaAjustedWeight = 1350;
pCurrentParams->consensus.nPowAveragingWindow = 45;
pCurrentParams->consensus.powAlternate = uint256S("0000000f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f");
}
if (ASSETCHAINS_LWMAPOS != 0)
{
pCurrentParams->consensus.posLimit = uint256S("000000000f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f");
pCurrentParams->consensus.nPOSAveragingWindow = 45;
// spacing is 1000 units per block to get better resolution, POS is 50% hard coded for now, we can vary it later
// when we get reliable integer math on nLwmaPOSAjustedWeight
pCurrentParams->consensus.nPOSTargetSpacing = VERUS_BLOCK_POSUNITS * 2;
// nLwmaPOSAjustedWeight = (N+1)/2 * (0.9989^(500/nPOSAveragingWindow)) * nPOSTargetSpacing
// this needs to be recalculated if VERUS_BLOCK_POSUNITS is changed
pCurrentParams->consensus.nLwmaPOSAjustedWeight = 46531;
}
// only require coinbase protection on Verus from the Komodo family of coins
if (strcmp(ASSETCHAINS_SYMBOL,"VRSC") == 0)
{
pCurrentParams->consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight = 227520;
pCurrentParams->consensus.vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight = 227520;
pCurrentParams->consensus.fCoinbaseMustBeProtected = true;
checkpointData = //(Checkpoints::CCheckpointData)
{
boost::assign::map_list_of
(0, pCurrentParams->consensus.hashGenesisBlock)
(10000, uint256S("0xac2cd7d37177140ea4991cf630c0b9c7f94d707b84fb0351bf3a44856d2ae5dc"))
(20000, uint256S("0xb0e8cb9f77aaa7ff5bd90d6c08d06f4c4bf03e00c2b8a35a042e760845590c8a"))
(30000, uint256S("0xf2112ca577338ad7104bf905fa6a63d36b17a86f914c97b73cd31d43fcd7557c"))
(40000, uint256S("0x00000000008f83378dab727864b763ce91a4ea5f75d55939c0c1390cfb8c38f1"))
(49170, uint256S("0x2add646c0089871ec2379f02f7cd60b3af6efd9c152a6f16fc10925458c270cc")),
(int64_t)1529910234, // * UNIX timestamp of last checkpoint block
(int64_t)63661, // * total number of transactions between genesis and last checkpoint
// (the tx=... number in the SetBestChain debug.log lines)
(double)2777 // * estimated number of transactions per day after checkpoint
// total number of tx / (checkpoint block height / (24 * 24))
};
pCurrentParams->consensus.nMinimumChainWork = uint256S("0x000000000000000000000000000000000000000000000001a8f4f23f8b2d1f7e");
}
else
{
if (strcmp(ASSETCHAINS_SYMBOL,"VRSCTEST") == 0 || strcmp(ASSETCHAINS_SYMBOL,"VERUSTEST") == 0)
{
pCurrentParams->consensus.nMinimumChainWork = uint256S("0x0000000000000000000000000000000000000000000000000000000000001f7e");
}
pCurrentParams->consensus.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight = ASSETCHAINS_SAPLING;
pCurrentParams->consensus.vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight = ASSETCHAINS_OVERWINTER;
checkpointData = //(Checkpoints::CCheckpointData)
{
boost::assign::map_list_of
(0, pCurrentParams->consensus.hashGenesisBlock),
(int64_t)1231006505,
(int64_t)1,
(double)2777 // * estimated number of transactions per day after checkpoint
// total number of tx / (checkpoint block height / (24 * 24))
};
}
}
else
{
checkpointData = //(Checkpoints::CCheckpointData)
{
boost::assign::map_list_of
(0, pCurrentParams->consensus.hashGenesisBlock)
( 5000, uint256S("0x049cfc91eef411e96603a42c9a77c5e30e9fe96f783ab818f4c00fb56fb29b6c"))
( 10000, uint256S("0x0a0169db3614311cd4181deb73cfcf7f640e7dc956cda34e0121a0351925e9ae"))
( 15000, uint256S("0x00f0bd236790e903321a2d22f85bd6bf8a505f6ef4eddb20458a65d37e14d142"))
( 20000, uint256S("0x01bbf0c38892bdcced62b538329cf63bc7badca3e7e1bff8eb10345436871c6e"))
( 25000, uint256S("0x04ca27808268dda8f942b647a6df844be1b263a661a13740293db962022d1f9e"))
( 30000, uint256S("0x04c9e8cfbcd37399085e529b50147de8afb80c76c48752c122d56f23316a7acb"))
( 35000, uint256S("0x00815f1240354cff7487c67f7dff78e248cb9053ed2c92751d1a9ad42d3eaedf"))
( 40000, uint256S("0x00eafd9dfb1e5f1bf1cca0c49be628538900daf69b665464443d29c2c3b6a2fe"))
( 45000, uint256S("0x0377730632caf694b92f40d03ae0fbe5bd86a1205014b71d975453ac793b0af9"))
( 50000, uint256S("0x00076e16d3fa5194da559c17cf9cf285e21d1f13154ae4f7c7b87919549345aa"))
( 55000, uint256S("0x0005a0701a83e05b639418ea4c87018544a4d22b2b49e5f111161e8ffc455108"))
( 60000, uint256S("0x0000296fc15f8599b7c6561d0e0a96f24766135ed79107b603d6dd6e55142c0d"))
( 65000, uint256S("0x000861f5d7970d5399733b4605074d47f877d6536f74ffae6f08e871ee29e6f2"))
( 70000, uint256S("0x0002af1d487c567526c517b52996944dca344e139cddca77c2e72f746e73b263"))
( 75000, uint256S("0x0d08129659be5f105e70c047769359eaf3475d61a726750859fdca3e1a2bf5cc"))
( 80000, uint256S("0x0af5f3f1caae4f08c74a82689731d1ef8e55107c06f9a996e251b8ecb96989ad"))
( 85000, uint256S("0x00000c8ee29086c5fb39eddad0619773b9ce936c77c13e5e5118a4998e939544"))
( 90000, uint256S("0x06d3bb7f9ee5b55f67b2dc13c680699a2f736f43a44b4e4cfd41a58aa00f063f"))
( 95000, uint256S("0x0670981b269879aae83a88f6f0c4db34763c93fd410d96435f2acb4e6580b976"))
( 100000, uint256S("0x0f02eb1f3a4b89df9909fec81a4bd7d023e32e24e1f5262d9fc2cc36a715be6f"))
( 105000, uint256S("0x018b97d7e6d259add24afe0e08fc125dc21d734e8831b68b430f5c3896deb4af"))
( 110000, uint256S("0x09644ff52734e0e911a9ba7ecd03cf7995b25301840a9637891ef9af69f59c32"))
( 115000, uint256S("0x0ee382b4729b8ceb918a92913f9c144a6a4f8a50bfc0f8b4aac5b12592caed7f"))
( 120000, uint256S("0x082a7918a0dd9cb2df65f55acb8d0a4a535b3fa684d92c3ebcb24ed7019d975b"))
( 125000, uint256S("0x00008f76c4484fd539c9d02fc69c40a50b6f9e00984d33890b85cc0324159e9e"))
( 130000, uint256S("0x011b09e53acfe46f310e8c960a9c4f4f490cc7b2cd3791d7a6a80d6e8ac96b36"))
( 135000, uint256S("0x01e0cd48358fa05646baa6f00e26717474d6049a537c8861b324d1f497dc3d4a"))
( 140000, uint256S("0x0e6db36fd8a9d1b7baf359c8bd5c76635d0bcada973a75b5d2028ca3baea4961"))
( 145000, uint256S("0x00010c40b57316ce6cde076807c9db956452a3c82cb09fe7d56c6bb1a7e24726"))
( 150000, uint256S("0x0a817f15b9da636f453a7a01835cfc534ed1a55ce7f08c566471d167678bedce"))
( 155000, uint256S("0x0528084fd00223bd9747635d7a4d8cc79f158795cad654efb78e4e4cc5f23d6a"))
( 160000, uint256S("0x00003a09f26ae9fb7ebbfa3ef589b81ccd8909a82430f7414bc68d5a5a3316ab"))
( 165000, uint256S("0x00004a0c6a29e7d1f22ea4e44d05e861fec5fcd8eebc5a61574c4ecf29dbb9be"))
( 170000, uint256S("0x0cf9eac27badc0ae9a2b370dd7cc3fcb550f139349551e60978f394a2e1b262b"))
( 175000, uint256S("0x0000137856b825d431da27ff4c3cf22f5482fa21952d45b0db0ec6774fb9b510"))
( 180000, uint256S("0x000000b0afcccf98aa0afb6ac61050892bd9415857d66313d1f67fd1bbac312f"))
( 185000, uint256S("0x00c2af8f88d84de080067f8ae1c25754e32e5516d20c11f85b9adae2d683687b"))
( 190000, uint256S("0x00000033d85b3e7d19e02278ef300b8ab957d3dd3e58b4c81166ba0a58af5c3f"))
( 195000, uint256S("0x000000964b6068be1dd4ee6893d183e86cba82a2744fb5439c463d0ba7e053b6"))
( 200000, uint256S("0x000001763a9337328651ca57ac487cc0507087be5838fb74ca4165ff19f0e84f"))
( 205000, uint256S("0x049fc6832e64a75ae898b32804e151e7561ea49082858c3d4af89a7de4b82f06"))
( 210000, uint256S("0x0000000d9078b9c9604cc663eafafba8f3643bb3f3ddbb78fed4993236e1edb5"))
( 215000, uint256S("0x00060089ecc21bcc62094e2f7f0448fe163415f6ef2f2aafe047757889ca82fe"))
( 220000, uint256S("0x000082c78e6c2a13a9c23dd7a6faaf962fc133142b4a2d07725561f59c03bfa2"))
( 225000, uint256S("0x00030026483167fe13505cf27049307ce42e0d9c5aa093aed10baa4f49edf4ca"))
( 230000, uint256S("0x000183a3e17988060a35776b99c1f0b43393bbe7153b2718dfc57f428191de4e"))
( 235000, uint256S("0x000184995f0ec024ed3783e322c8cfa5e68d9f0c77c3aaea301b22d311619156"))
( 240000, uint256S("0x0000002cc7cf6d0a44ab57f9bd3bfa11a865bbf1cd87a2081095bc90981633a3"))
( 245000, uint256S("0x004c5f19a88c8fe8a604006dbd2d44c94baef2a00876a17d8e2be2124003f979"))
( 250000, uint256S("0x0dd54ef5f816c7fde9d2b1c8c1a26412b3c761cc5dd3901fa5c4cd1900892fba"))
( 255000, uint256S("0x0b6da9e4f50c8bc7a92c539bc7474ffd6c29e0a8531f0dbbbc261fff1f990827"))
( 260000, uint256S("0x0cac8b12bf7233ee5a68fcde9e251852b177833fefa2a9f39ec28474b0851cb9"))
( 265000, uint256S("0x04feb5b4029f3b8b8eb3e6661a78eadd1a26b4af00ac59b5f05b261afcfd2818"))
( 270000, uint256S("0x01bc5897bd20b8b61acf4989987ba85fbc37d9ebe848924aa8effcb08bf48fe0"))
( 275000, uint256S("0x0416bc29eb5a12231826e546ba90fcd38aeef387ff77b45849cd418a9c1a6f12"))
( 280000, uint256S("0x000007593e9880b171d46bce59aa0cec2a1b1f53d1fd7e8f71ccb2b9182374a4"))
( 285000, uint256S("0x05a338b2d90cd79740221fe8635b7a834f2e486fcbb2464a4294f5a21231a5f5"))
( 290000, uint256S("0x064ca3912cdcd833702d07a530e98bc5c6c1cd738a8825c7240b17cd68ca0cc4"))
( 295000, uint256S("0x036b3bb318d743fd78db983a9aadd52869991d48913c4eebe2a074387d67cc5a"))
( 300000, uint256S("0x000000fa5efd1998959926047727519ed7de06dcf9f2cd92a4f71e907e1312dc"))
( 305000, uint256S("0x00003656231e83de2348755153ed175794696a113d7e8a15c01f90fdb7c2f287"))
( 310000, uint256S("0x0cf6baf727eb931da0813ed8b032648c4766be79e146b0d40c643f9d8edf40f7"))
( 315000, uint256S("0x082469974c152ebe69f1787f0d06aa5d9dd1dc69c880febde7eac2bc800146dd"))
( 320000, uint256S("0x0000063df36b99bfb2516f55cb548a5baed1f2d8ae69c3559dc478c5c2eb32df"))
( 325000, uint256S("0x0cb926b303a1514ba0a2f729af88ccb143517f396e9e0bde09b0736900698e0f"))
( 330000, uint256S("0x000000be3d8bb6e31c3b534819aae7014cbbe9a44ab3e799dc1bfc724c6ab184"))
( 335000, uint256S("0x0d0756608189fd5bbd8ec50e76180074e69e973439cc09df49134e4cb970ed4d"))
( 340000, uint256S("0x0d814eacdb9c97003d703c0ff79b1b97b9ed8615fe12b1afaede946e5fdfe0a7"))
( 345000, uint256S("0x000000c2910f510f1de325d300202da1a391f2719dd378173299151c3da94e85"))
( 350000, uint256S("0x0000000228ef321323f81dae00c98d7960fc7486fb2d881007fee60d1e34653f"))
( 355000, uint256S("0x03e6a55e382b478e0fab9c3584da3629fd9b977986a333a406b24b0d3559bf44"))
( 360000, uint256S("0x0859c86dd718bcb5b58af06389197794e2beea6239653f2e6fa7b8a7433d29ea"))
( 365000, uint256S("0x07896332665c707a8f55398a998e7878e8d2681ba79dd95c2859b1dafc9343d0"))
( 370000, uint256S("0x040efd8c64cf5cf96ecf75468741a8880d1386eb5e349bef0a55116d4023944c"))
( 375000, uint256S("0x053029e7599a09fe6c01203997d7ca738dd4c6d216a433695a0d514def1eccc0"))
( 380000, uint256S("0x0cae44e7a421c389b88a5a204d3e39779e93aeacaab1b693741bf279fd0c8acd"))
( 385000, uint256S("0x0b4032d2c799ba93644231ce57134dd24e13ec0dc267c1ed5912389691d2bd72"))
( 390000, uint256S("0x0afd0f166f33a881ef289af7ea7010d58c4bbd560dee10b561c79e1b8dfd0593"))
( 395000, uint256S("0x083774b88cf1b138d67c242d9b33c54f69d7e901b5e8144dc4a2303ab9927102"))
( 400000, uint256S("0x036d294c5be96f4c0efb28e652eb3968231e87204a823991a85c5fdab3c43ae6"))
( 405000, uint256S("0x0522e33bb2161fb1b33acef9a4a438fcf420dcae8a0b472e234d223d731c42b2"))
( 410000, uint256S("0x0361d06aa807c66b87befea8119a485341d1118b694c3dbb4c3cf0b85ac69e9b"))
( 415000, uint256S("0x072d5653d8673f64ef8b9c655f7b8021072070a072b799013ff6e96de99a59e6"))
( 420000, uint256S("0x013b693d66955be69d4501cb1d307ca323a5c8473e25866ae7e700cdce0c654f"))
( 425000, uint256S("0x0ef0c55af27c6971289a790dee2b2ec728fb9c6555ff9306c07f1083cf0fb4b5"))
( 430000, uint256S("0x0ccbeeaba28291e0316a9cf54c005097c61dc67ba6f32283406d6c83b828da00"))
( 435000, uint256S("0x020ed6b7fe1124400baba7feed463ba0c90e7e6903493fdc1a1a18c4a506055a"))
( 440000, uint256S("0x055aaadca1908abeedc831a3f9115aa31284fc223d010590caf7b612960b61a4"))
( 445000, uint256S("0x06d2327fa25ea7e2be742fc0e45fc4f9adb41811f21be0357f8543c5434df715"))
( 450000, uint256S("0x0906ef1e8dc194f1f03bd4ce1ac8c6992fd721ef2c5ccbf4871ec8cdbb456c18"))
( 455000, uint256S("0x0b8b92eec29eb20262dcf9916f0ca36d6abf0c39d321d3f480a5535cb978db71"))
( 460000, uint256S("0x0cb04591f69a255b1127aaff3bbd59eaa21a5d9cca999de197516c251895c536"))
( 465000, uint256S("0x029985ae78d8bb8fd170aeb3ab02ea76134ed0c19ae00211cc28a61fe5755b88"))
( 470000, uint256S("0x01a2f4b56f37b223e75572862ad1ba956ec179332f8cd40590d7253563c86ba8"))
( 475000, uint256S("0x0a34c6f9d4d9cb8c78c14b8041a7cc1874cfcbb22a34a5c068d1d6ff3ed9fdf0"))
( 480000, uint256S("0x0ebab25030179996ae25969f34f6a297c7ffce1994f9b4186082a47032a9a7dc"))
( 485000, uint256S("0x06a096e6bccf3b85537a30f95db6a414deacc0509bc84da264c2830df1a1d9b0"))
( 490000, uint256S("0x0af828930ef13405cb536b88a3d1d4e0d84dc79ee260402c56bfa86e261c74ff"))
( 495000, uint256S("0x09d44905bfd12849d3c2178b2ba882f8e9d6565b6e4d7a97c70a92bd6de7c5e6"))
( 500000, uint256S("0x0bebdb417f7a51fe0c36fcf94e2ed29895a9a862eaa61601272866a7ecd6391b"))
( 505000, uint256S("0x0c1609f4f3561baa1fc975877948af94d2107c88686a9821bc240016cc87d953"))
( 510000, uint256S("0x0cf9a5a4997b871e615e5e398627e45fa15b3e6970ae22b47bdd11b0f5fa0fa7"))
( 515000, uint256S("0x034171d4819e9961de13309743a32a179abede97d60ea64101dc04c97a1a0807"))
( 520000, uint256S("0x0648fa44d5bbc2cc04a782e083c11df64ac06185f0f8e11a7416625ebb6409a6"))
( 525000, uint256S("0x0000000ef17d63af3159e52cd351b6f000536ad88adc3a937bb747955fed58a2"))
( 530000, uint256S("0x08e3af153995ba09e50086b64145cf4cd57db6b29f16f06f28d80d7f6121cfad"))
( 535000, uint256S("0x02a0ffd00b51e2061b85de50a9223d9c84f4e357dc1046397bb9d7d4a827a3fb"))
( 540000, uint256S("0x04bf07d026af29025c1ac2815e067f4a41d2872701ac9780eb3015d51cdcd854"))
( 545000, uint256S("0x0a0d6d86635946792ad0dca57ed227a5360fc8b6d79e47132aac11e90a4963ce"))
( 550000, uint256S("0x06df52fc5f9ba03ccc3a7673b01ab47990bd5c4947f6e1bc0ba14d21cd5bcccd"))
( 555000, uint256S("0x0baf38eea8e08fcad3a9d760f27377e79c291b08e7fb4920cadd5cb7bab547f3"))
( 560000, uint256S("0x00000004c34abbf1366adbae965b644c01debf15409acc715ff51cb221d92dd7"))
( 565000, uint256S("0x067bae7119f083e0fa1820bc8e25dcfa7717e42aabaef18beefd87d974953dfb"))
( 570000, uint256S("0x00000011a7ce7b628b7be17777d8dea2574d83f165e23c9e44aa705975820fd3"))
( 575000, uint256S("0x0e1110a193a30d3f8d369017233a2486b11c748b3d033859a2eb7b37062d303e"))
( 580000, uint256S("0x083cb58484aff80f48e3537e0451d49e544b3efa3da97274800c91e567d33a92"))
( 585000, uint256S("0x0224cf835428d03472edf4f7b6fcc63b9d8d6f1d5a90ad8186bf123d541b4ea8"))
( 590000, uint256S("0x0cfcf3b9517894e4df49db5faf8b74f3a9e01eb83c0cc5051c115d4424615dae"))
( 595000, uint256S("0x0000000a45266983dd81e0df381a3b0455699b2f76d5b4d3f17b87d657a1b56d"))
( 600000, uint256S("0x00000005080d5689c3b4466e551cd1986e5d2024a62a79b1335afe12c42779e4"))
( 605000, uint256S("0x0000001c691da36848542299af859d4eb3fa408a0f425b1fbe6d622d2100623a"))
( 610000, uint256S("0x040d8c7a0ac89e3ed8605a198583a795986aacbf18722a9897d7b925bcf757f6"))
( 615000, uint256S("0x0449cf00fc36206389c14cbf1d762f8b96bb0440ccea5b46703e7c69b0e2bc42"))
( 620000, uint256S("0x07227a41340c25ee1a7e9b60414259780202ffa990079fc91d8faeac9af03e60"))
( 625000, uint256S("0x047c2472fe2afabb3d38decf24bba4ba712b60e7a1782f4afae3ede3f912f493"))
( 630000, uint256S("0x0a7f1f04e66260cf972ab1374a9126b8abc1adaa3ab4669db5d4d4ddb9ad493d"))
( 635000, uint256S("0x048df95165eb821dabf37ef28cf7f3be72e216e95377684253dab806985b50a4"))
( 640000, uint256S("0x066b3c6a6a3c8dc58bef509a972c3e3ade14493b40e1b361ecbc928134e302be"))
( 645000, uint256S("0x07d059888c9ade3bbe16d6b4d70ee9b8302d104b37a3c6cd61f81012aabd0e1e"))
( 650000, uint256S("0x039a3cb760cc6e564974caf69e8ae621c14567f3a36e4991f77fd869294b1d52"))
( 655000, uint256S("0x089350ee8d28b44837eb4b1fe77704953d5de2077f10c74a888d9d3ea1e13c2a"))
( 660000, uint256S("0x000000023f8a582a61ae2f6fab6fe8197e79b7a68aaac67432421b09f1bdd4ba"))
( 665000, uint256S("0x0b16edce865e7a0d662115774e0c0d3abbf9c69004155b693ddc933f051bfb26"))
( 670000, uint256S("0x09070b109b089490bc372fd8358abae352d6db0e46ade6ed2200e4d4ff7aa6af"))
( 675000, uint256S("0x08d9edeed3b6ac55991e9f32af0218ff8fa9dc808078623f4c831eb09d4f186b"))
( 680000, uint256S("0x00000003eb2b30bfac929d3496acecab19625ac9f854a86aaf9678bea99e1cc1"))
( 681777, uint256S("0x0000243296b9b26c040f471fdd9398ef72e57062cf05c19b9ba2fefac8165306")),
(int64_t)1516924927, // * UNIX timestamp of last checkpoint block
(int64_t)1253783, // * total number of transactions between genesis and last checkpoint
// (the tx=... number in the SetBestChain debug.log lines)
(double)2777 // * estimated number of transactions per day after checkpoint
// total number of tx / (checkpoint block height / (24 * 24))
};
}
pCurrentParams->SetCheckpointData(checkpointData);
ASSETCHAIN_INIT = 1;
return(0);
}

View File

@@ -21,6 +21,14 @@
extern int32_t KOMODO_NSPV; extern int32_t KOMODO_NSPV;
#define NSPV_BRANCHID 0x76b809bb #define NSPV_BRANCHID 0x76b809bb
#ifndef KOMODO_NSPV_FULLNODE
#define KOMODO_NSPV_FULLNODE (KOMODO_NSPV <= 0)
#endif // !KOMODO_NSPV_FULLNODE
#ifndef KOMODO_NSPV_SUPERLITE
#define KOMODO_NSPV_SUPERLITE (KOMODO_NSPV > 0)
#endif // !KOMODO_NSPV_SUPERLITE
/** /**
* General information about each network upgrade. * General information about each network upgrade.
* Ordered by Consensus::UpgradeIndex. * Ordered by Consensus::UpgradeIndex.
@@ -101,7 +109,7 @@ int CurrentEpoch(int nHeight, const Consensus::Params& params) {
uint32_t CurrentEpochBranchId(int nHeight, const Consensus::Params& params) uint32_t CurrentEpochBranchId(int nHeight, const Consensus::Params& params)
{ {
if ( KOMODO_NSPV > 0 ) if ( KOMODO_NSPV_SUPERLITE )
return(NSPV_BRANCHID); return(NSPV_BRANCHID);
return NetworkUpgradeInfo[CurrentEpoch(nHeight, params)].nBranchId; return NetworkUpgradeInfo[CurrentEpoch(nHeight, params)].nBranchId;
} }

View File

@@ -272,10 +272,10 @@ int cc_verify(const struct CC *cond, const unsigned char *msg, size_t msgLength,
unsigned char msgHash[32]; unsigned char msgHash[32];
if (doHashMsg) sha256(msg, msgLength, msgHash); if (doHashMsg) sha256(msg, msgLength, msgHash);
else memcpy(msgHash, msg, 32); else memcpy(msgHash, msg, 32);
int32_t z; //int32_t z;
for (z=0; z<32; z++) //for (z=0; z<32; z++)
fprintf(stderr,"%02x",msgHash[z]); // fprintf(stderr,"%02x",msgHash[z]);
fprintf(stderr," msgHash msglen.%d\n",msgLength); //fprintf(stderr," msgHash msglen.%d\n",(int32_t)msgLength);
if (!cc_secp256k1VerifyTreeMsg32(cond, msgHash)) { if (!cc_secp256k1VerifyTreeMsg32(cond, msgHash)) {
fprintf(stderr," cc_verify error C\n"); fprintf(stderr," cc_verify error C\n");

View File

@@ -1,8 +1,9 @@
#!/bin/bash #!/bin/bash
args="$@" args="$@"
komodo_cli='./komodo-cli'
./listassetchains | while read chain; do ./listassetchains | while read chain; do
echo $chain echo $chain
./komodo-cli --ac_name=$chain $args $komodo_cli --ac_name=$chain $args
done done

View File

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

2
src/fiat/coquicash Executable file
View File

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

2
src/fiat/thc Executable file
View File

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

View File

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

View File

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

View File

@@ -75,7 +75,9 @@
#include <boost/function.hpp> #include <boost/function.hpp>
#include <boost/interprocess/sync/file_lock.hpp> #include <boost/interprocess/sync/file_lock.hpp>
#include <boost/thread.hpp> #include <boost/thread.hpp>
#include <chrono>
#include <openssl/crypto.h> #include <openssl/crypto.h>
#include <thread>
#include <libsnark/common/profiling.hpp> #include <libsnark/common/profiling.hpp>
@@ -95,6 +97,7 @@ using namespace std;
extern void ThreadSendAlert(); extern void ThreadSendAlert();
extern bool komodo_dailysnapshot(int32_t height); extern bool komodo_dailysnapshot(int32_t height);
extern int32_t KOMODO_LOADINGBLOCKS; extern int32_t KOMODO_LOADINGBLOCKS;
extern void komodo_init(int32_t height);
ZCJoinSplit* pzcashParams = NULL; ZCJoinSplit* pzcashParams = NULL;
@@ -727,6 +730,22 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
} }
} }
void ThreadNotifyRecentlyAdded()
{
while (true) {
// Run the notifier on an integer second in the steady clock.
auto now = std::chrono::steady_clock::now().time_since_epoch();
auto nextFire = std::chrono::duration_cast<std::chrono::seconds>(
now + std::chrono::seconds(1));
std::this_thread::sleep_until(
std::chrono::time_point<std::chrono::steady_clock>(nextFire));
boost::this_thread::interruption_point();
mempool.NotifyRecentlyAdded();
}
}
/** Sanity checks /** Sanity checks
* Ensure that Bitcoin is running in a usable environment with all * Ensure that Bitcoin is running in a usable environment with all
* necessary library support. * necessary library support.
@@ -1088,7 +1107,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
RegisterAllCoreRPCCommands(tableRPC); RegisterAllCoreRPCCommands(tableRPC);
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
bool fDisableWallet = GetBoolArg("-disablewallet", false); bool fDisableWallet = GetBoolArg("-disablewallet", false);
if ( KOMODO_NSPV > 0 ) if ( KOMODO_NSPV_SUPERLITE )
{ {
fDisableWallet = true; fDisableWallet = true;
nLocalServices = 0; nLocalServices = 0;
@@ -1169,7 +1188,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
// Option to startup with mocktime set (used for regression testing): // Option to startup with mocktime set (used for regression testing):
SetMockTime(GetArg("-mocktime", 0)); // SetMockTime(0) is a no-op SetMockTime(GetArg("-mocktime", 0)); // SetMockTime(0) is a no-op
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
{ {
if (GetBoolArg("-peerbloomfilters", true)) if (GetBoolArg("-peerbloomfilters", true))
nLocalServices |= NODE_BLOOM; nLocalServices |= NODE_BLOOM;
@@ -1333,7 +1352,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
libsnark::inhibit_profiling_info = true; libsnark::inhibit_profiling_info = true;
libsnark::inhibit_profiling_counters = true; libsnark::inhibit_profiling_counters = true;
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
{ {
// Initialize Zcash circuit parameters // Initialize Zcash circuit parameters
ZC_LoadParams(chainparams); ZC_LoadParams(chainparams);
@@ -1514,7 +1533,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
} }
#endif #endif
if ( KOMODO_NSPV > 0 ) if ( KOMODO_NSPV_SUPERLITE )
{ {
std::vector<boost::filesystem::path> vImportFiles; std::vector<boost::filesystem::path> vImportFiles;
threadGroup.create_thread(boost::bind(&ThreadImport, vImportFiles)); threadGroup.create_thread(boost::bind(&ThreadImport, vImportFiles));
@@ -1655,7 +1674,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
// (we're likely using a testnet datadir, or the other way around). // (we're likely using a testnet datadir, or the other way around).
if (!mapBlockIndex.empty() && mapBlockIndex.count(chainparams.GetConsensus().hashGenesisBlock) == 0) if (!mapBlockIndex.empty() && mapBlockIndex.count(chainparams.GetConsensus().hashGenesisBlock) == 0)
return InitError(_("Incorrect or no genesis block found. Wrong datadir for network?")); return InitError(_("Incorrect or no genesis block found. Wrong datadir for network?"));
komodo_init(1);
// Initialize the block index (no-op if non-empty database was already loaded) // Initialize the block index (no-op if non-empty database was already loaded)
if (!InitBlockIndex()) { if (!InitBlockIndex()) {
strLoadError = _("Error initializing block database"); strLoadError = _("Error initializing block database");
@@ -1990,6 +2009,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
LogPrintf("mapAddressBook.size() = %u\n", pwalletMain ? pwalletMain->mapAddressBook.size() : 0); LogPrintf("mapAddressBook.size() = %u\n", pwalletMain ? pwalletMain->mapAddressBook.size() : 0);
#endif #endif
// Start the thread that notifies listeners of transactions that have been
// recently added to the mempool.
threadGroup.create_thread(boost::bind(&TraceThread<void (*)()>, "txnotify", &ThreadNotifyRecentlyAdded));
if (GetBoolArg("-listenonion", DEFAULT_LISTEN_ONION)) if (GetBoolArg("-listenonion", DEFAULT_LISTEN_ONION))
StartTorControl(threadGroup, scheduler); StartTorControl(threadGroup, scheduler);

View File

@@ -67,9 +67,14 @@ void komodo_currentheight_set(int32_t height)
sp->CURRENT_HEIGHT = height; sp->CURRENT_HEIGHT = height;
} }
extern struct NSPV_inforesp NSPV_inforesult;
int32_t komodo_currentheight() int32_t komodo_currentheight()
{ {
char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp;
if ( KOMODO_NSPV_SUPERLITE )
{
return (NSPV_inforesult.height);
}
if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) if ( (sp= komodo_stateptr(symbol,dest)) != 0 )
return(sp->CURRENT_HEIGHT); return(sp->CURRENT_HEIGHT);
else return(0); else return(0);

View File

@@ -20,7 +20,7 @@
#include "komodo_nk.h" #include "komodo_nk.h"
#define KOMODO_EARLYTXID_HEIGHT 100 #define KOMODO_EARLYTXID_HEIGHT 100
#define ADAPTIVEPOW_CHANGETO_DEFAULTON 1572480000 //#define ADAPTIVEPOW_CHANGETO_DEFAULTON 1572480000
#define ASSETCHAINS_MINHEIGHT 128 #define ASSETCHAINS_MINHEIGHT 128
#define ASSETCHAINS_MAX_ERAS 7 #define ASSETCHAINS_MAX_ERAS 7
#define KOMODO_ELECTION_GAP 2000 #define KOMODO_ELECTION_GAP 2000
@@ -345,4 +345,11 @@ arith_uint256 komodo_adaptivepow_target(int32_t height,arith_uint256 bnTarget,ui
uint256 Parseuint256(const char *hexstr); uint256 Parseuint256(const char *hexstr);
#ifndef KOMODO_NSPV_FULLNODE
#define KOMODO_NSPV_FULLNODE (KOMODO_NSPV <= 0)
#endif // !KOMODO_NSPV_FULLNODE
#ifndef KOMODO_NSPV_SUPERLITE
#define KOMODO_NSPV_SUPERLITE (KOMODO_NSPV > 0)
#endif // !KOMODO_NSPV_SUPERLITE
#endif #endif

View File

@@ -1420,7 +1420,7 @@ void komodo_passport_iteration()
int32_t maxseconds = 10; int32_t maxseconds = 10;
FILE *fp; uint8_t *filedata; long fpos,datalen,lastfpos; int32_t baseid,limit,n,ht,isrealtime,expired,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; uint32_t buf[3],starttime; uint64_t RTmask = 0; //CBlockIndex *pindex; FILE *fp; uint8_t *filedata; long fpos,datalen,lastfpos; int32_t baseid,limit,n,ht,isrealtime,expired,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; uint32_t buf[3],starttime; uint64_t RTmask = 0; //CBlockIndex *pindex;
expired = 0; expired = 0;
while ( KOMODO_INITDONE == 0 ) while ( 0 && KOMODO_INITDONE == 0 )
{ {
fprintf(stderr,"[%s] PASSPORT iteration waiting for KOMODO_INITDONE\n",ASSETCHAINS_SYMBOL); fprintf(stderr,"[%s] PASSPORT iteration waiting for KOMODO_INITDONE\n",ASSETCHAINS_SYMBOL);
sleep(3); sleep(3);

View File

@@ -17,7 +17,7 @@
#ifndef KOMODO_NSPV_DEFSH #ifndef KOMODO_NSPV_DEFSH
#define KOMODO_NSPV_DEFSH #define KOMODO_NSPV_DEFSH
#define NSPV_PROTOCOL_VERSION 0x00000002 #define NSPV_PROTOCOL_VERSION 0x00000004
#define NSPV_POLLITERS 200 #define NSPV_POLLITERS 200
#define NSPV_POLLMICROS 50000 #define NSPV_POLLMICROS 50000
#define NSPV_MAXVINS 64 #define NSPV_MAXVINS 64
@@ -49,6 +49,7 @@
#define NSPV_MEMPOOL_ISSPENT 2 #define NSPV_MEMPOOL_ISSPENT 2
#define NSPV_MEMPOOL_INMEMPOOL 3 #define NSPV_MEMPOOL_INMEMPOOL 3
#define NSPV_MEMPOOL_CCEVALCODE 4 #define NSPV_MEMPOOL_CCEVALCODE 4
#define NSPV_CC_TXIDS 16
int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int32_t height,CTransaction &tx,uint256 &hashblock,int32_t &txheight,int32_t &currentheight,int64_t extradata,uint32_t tiptime,int64_t &rewardsum); int32_t NSPV_gettransaction(int32_t skipvalidation,int32_t vout,uint256 txid,int32_t height,CTransaction &tx,uint256 &hashblock,int32_t &txheight,int32_t &currentheight,int64_t extradata,uint32_t tiptime,int64_t &rewardsum);
UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis); UniValue NSPV_spend(char *srcaddr,char *destaddr,int64_t satoshis);

View File

@@ -172,7 +172,7 @@ int32_t NSPV_getaddressutxos(struct NSPV_utxosresp *ptr,char *coinaddr,bool isCC
{ {
// if gettxout is != null to handle mempool // if gettxout is != null to handle mempool
{ {
if ( n >= skipcount ) if ( n >= skipcount && myIsutxo_spentinmempool(ignoretxid,ignorevin,it->first.txhash,(int32_t)it->first.index) == 0 )
{ {
ptr->utxos[ind].txid = it->first.txhash; ptr->utxos[ind].txid = it->first.txhash;
ptr->utxos[ind].vout = (int32_t)it->first.index; ptr->utxos[ind].vout = (int32_t)it->first.index;
@@ -208,7 +208,7 @@ int32_t NSPV_getaddressutxos(struct NSPV_utxosresp *ptr,char *coinaddr,bool isCC
int32_t NSPV_getaddresstxids(struct NSPV_txidsresp *ptr,char *coinaddr,bool isCC,int32_t skipcount,uint32_t filter) int32_t NSPV_getaddresstxids(struct NSPV_txidsresp *ptr,char *coinaddr,bool isCC,int32_t skipcount,uint32_t filter)
{ {
int32_t maxlen,txheight,ind=0,n = 0,len = 0; int32_t maxlen,txheight,ind=0,n = 0,len = 0; CTransaction tx; uint256 hashBlock;
std::vector<std::pair<CAddressIndexKey, CAmount> > txids; std::vector<std::pair<CAddressIndexKey, CAmount> > txids;
SetCCtxids(txids,coinaddr,isCC); SetCCtxids(txids,coinaddr,isCC);
ptr->nodeheight = chainActive.LastTip()->GetHeight(); ptr->nodeheight = chainActive.LastTip()->GetHeight();
@@ -250,10 +250,62 @@ int32_t NSPV_getaddresstxids(struct NSPV_txidsresp *ptr,char *coinaddr,bool isCC
return(0); return(0);
} }
int32_t NSPV_mempoolfuncs(int32_t *vindexp,std::vector<uint256> &txids,char *coinaddr,bool isCC,uint8_t funcid,uint256 txid,int32_t vout) int32_t NSPV_mempoolfuncs(bits256 *satoshisp,int32_t *vindexp,std::vector<uint256> &txids,char *coinaddr,bool isCC,uint8_t funcid,uint256 txid,int32_t vout)
{ {
int32_t num = 0,vini = 0,vouti = 0; uint8_t evalcode=0,func=0; std::vector<uint8_t> vopret; char destaddr[64]; int32_t num = 0,vini = 0,vouti = 0; uint8_t evalcode=0,func=0; std::vector<uint8_t> vopret; char destaddr[64];
*vindexp = -1; *vindexp = -1;
memset(satoshisp,0,sizeof(*satoshisp));
if ( funcid == NSPV_CC_TXIDS)
{
std::vector<std::pair<CAddressIndexKey, CAmount> > tmp_txids; uint256 tmp_txid,hashBlock;
int32_t n=0,skipcount=vout>>16; uint8_t eval=(vout>>8)&0xFF, func=vout&0xFF;
CTransaction tx;
SetCCtxids(tmp_txids,coinaddr,isCC);
if ( skipcount < 0 ) skipcount = 0;
if ( skipcount >= tmp_txids.size() )
skipcount = tmp_txids.size()-1;
if ( tmp_txids.size()-skipcount > 0 )
{
for (std::vector<std::pair<CAddressIndexKey, CAmount> >::const_iterator it=tmp_txids.begin(); it!=tmp_txids.end(); it++)
{
if (txid!=zeroid || func!=0)
{
myGetTransaction(it->first.txhash,tx,hashBlock);
std::vector<std::pair<uint8_t, vscript_t>> oprets; uint256 tokenid,txid;
std::vector<uint8_t> vopret,vOpretExtra; uint8_t *script,e,f,tokenevalcode;
std::vector<CPubKey> pubkeys;
if (DecodeTokenOpRet(tx.vout[tx.vout.size()-1].scriptPubKey,tokenevalcode,tokenid,pubkeys,oprets)!=0 && GetOpretBlob(oprets, OPRETID_CHANNELSDATA, vOpretExtra) && tokenevalcode==EVAL_TOKENS && vOpretExtra.size()>0)
{
vopret=vOpretExtra;
}
else GetOpReturnData(tx.vout[tx.vout.size()-1].scriptPubKey, vopret);
script = (uint8_t *)vopret.data();
if ( vopret.size() > 2 && script[0]==eval )
{
switch (eval)
{
case EVAL_CHANNELS:EVAL_PEGS:EVAL_ORACLES:EVAL_GAMES:EVAL_IMPORTGATEWAY:EVAL_ROGUE:
E_UNMARSHAL(vopret,ss >> e; ss >> f; ss >> tmp_txid;);
if (e!=eval || (txid!=zeroid && txid!=tmp_txid) || (func!=0 && f!=func)) continue;
break;
case EVAL_TOKENS:EVAL_DICE:EVAL_DILITHIUM:EVAL_FAUCET:EVAL_LOTO:EVAL_PAYMENTS:EVAL_REWARDS:
E_UNMARSHAL(vopret,ss >> e; ss >> f;);
if (e!=eval || (func!=0 && f!=func)) continue;
break;
default:
break;
}
}
}
if ( n >= skipcount ) txids.push_back(it->first.txhash);
n++;
}
return (n-skipcount);
}
return (0);
}
if ( mempool.size() == 0 ) if ( mempool.size() == 0 )
return(0); return(0);
if ( funcid == NSPV_MEMPOOL_CCEVALCODE ) if ( funcid == NSPV_MEMPOOL_CCEVALCODE )
@@ -323,6 +375,8 @@ int32_t NSPV_mempoolfuncs(int32_t *vindexp,std::vector<uint256> &txids,char *coi
{ {
txids.push_back(hash); txids.push_back(hash);
*vindexp = vouti; *vindexp = vouti;
if ( num < 4 )
satoshisp->ulongs[num] = txout.nValue;
num++; num++;
} }
} }
@@ -336,14 +390,14 @@ int32_t NSPV_mempoolfuncs(int32_t *vindexp,std::vector<uint256> &txids,char *coi
int32_t NSPV_mempooltxids(struct NSPV_mempoolresp *ptr,char *coinaddr,uint8_t isCC,uint8_t funcid,uint256 txid,int32_t vout) int32_t NSPV_mempooltxids(struct NSPV_mempoolresp *ptr,char *coinaddr,uint8_t isCC,uint8_t funcid,uint256 txid,int32_t vout)
{ {
std::vector<uint256> txids; uint256 tmp,tmpdest; int32_t i,len = 0; std::vector<uint256> txids; bits256 satoshis; uint256 tmp,tmpdest; int32_t i,len = 0;
ptr->nodeheight = chainActive.LastTip()->GetHeight(); ptr->nodeheight = chainActive.LastTip()->GetHeight();
strncpy(ptr->coinaddr,coinaddr,sizeof(ptr->coinaddr)-1); strncpy(ptr->coinaddr,coinaddr,sizeof(ptr->coinaddr)-1);
ptr->CCflag = isCC; ptr->CCflag = isCC;
ptr->txid = txid; ptr->txid = txid;
ptr->vout = vout; ptr->vout = vout;
ptr->funcid = funcid; ptr->funcid = funcid;
if ( NSPV_mempoolfuncs(&ptr->vindex,txids,coinaddr,isCC,funcid,txid,vout) >= 0 ) if ( NSPV_mempoolfuncs(&satoshis,&ptr->vindex,txids,coinaddr,isCC,funcid,txid,vout) >= 0 )
{ {
if ( (ptr->numtxids= (int32_t)txids.size()) >= 0 ) if ( (ptr->numtxids= (int32_t)txids.size()) >= 0 )
{ {
@@ -356,6 +410,11 @@ int32_t NSPV_mempooltxids(struct NSPV_mempoolresp *ptr,char *coinaddr,uint8_t is
iguana_rwbignum(0,(uint8_t *)&tmp,sizeof(*ptr->txids),(uint8_t *)&ptr->txids[i]); iguana_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);
}
len = (int32_t)(sizeof(*ptr) + sizeof(*ptr->txids)*ptr->numtxids - sizeof(ptr->txids)); len = (int32_t)(sizeof(*ptr) + sizeof(*ptr->txids)*ptr->numtxids - sizeof(ptr->txids));
return(len); return(len);
} }
@@ -413,46 +472,48 @@ int32_t NSPV_sendrawtransaction(struct NSPV_broadcastresp *ptr,uint8_t *data,int
int32_t NSPV_gettxproof(struct NSPV_txproof *ptr,int32_t vout,uint256 txid,int32_t height) int32_t NSPV_gettxproof(struct NSPV_txproof *ptr,int32_t vout,uint256 txid,int32_t height)
{ {
int32_t flag = 0,len = 0; CTransaction _tx; uint256 hashBlock; CBlock block; CBlockIndex *pindex; int32_t flag = 0,len = 0; CTransaction _tx; uint256 hashBlock; CBlock block; CBlockIndex *pindex;
if ( (ptr->tx= NSPV_getrawtx(_tx,hashBlock,&ptr->txlen,txid)) == 0 ) ptr->height = -1;
return(-1); if ( (ptr->tx= NSPV_getrawtx(_tx,hashBlock,&ptr->txlen,txid)) != 0 )
ptr->txid = txid;
ptr->vout = vout;
ptr->hashblock = hashBlock;
if ( height == 0 )
ptr->height = komodo_blockheight(hashBlock);
else
{ {
ptr->height = height; ptr->txid = txid;
if ( (pindex= komodo_chainactive(height)) != 0 && komodo_blockload(block,pindex) == 0 ) ptr->vout = vout;
ptr->hashblock = hashBlock;
if ( height == 0 )
ptr->height = komodo_blockheight(hashBlock);
else
{ {
BOOST_FOREACH(const CTransaction&tx, block.vtx) ptr->height = height;
if ( (pindex= komodo_chainactive(height)) != 0 && komodo_blockload(block,pindex) == 0 )
{ {
if ( tx.GetHash() == txid ) BOOST_FOREACH(const CTransaction&tx, block.vtx)
{ {
flag = 1; if ( tx.GetHash() == txid )
break; {
flag = 1;
break;
}
} }
} if ( flag != 0 )
if ( flag != 0 )
{
set<uint256> setTxids;
CDataStream ssMB(SER_NETWORK, PROTOCOL_VERSION);
setTxids.insert(txid);
CMerkleBlock mb(block, setTxids);
ssMB << mb;
std::vector<uint8_t> proof(ssMB.begin(), ssMB.end());
ptr->txprooflen = (int32_t)proof.size();
//fprintf(stderr,"%s txproof.(%s)\n",txid.GetHex().c_str(),HexStr(proof).c_str());
if ( ptr->txprooflen > 0 )
{ {
ptr->txproof = (uint8_t *)calloc(1,ptr->txprooflen); set<uint256> setTxids;
memcpy(ptr->txproof,&proof[0],ptr->txprooflen); CDataStream ssMB(SER_NETWORK, PROTOCOL_VERSION);
setTxids.insert(txid);
CMerkleBlock mb(block, setTxids);
ssMB << mb;
std::vector<uint8_t> proof(ssMB.begin(), ssMB.end());
ptr->txprooflen = (int32_t)proof.size();
//fprintf(stderr,"%s txproof.(%s)\n",txid.GetHex().c_str(),HexStr(proof).c_str());
if ( ptr->txprooflen > 0 )
{
ptr->txproof = (uint8_t *)calloc(1,ptr->txprooflen);
memcpy(ptr->txproof,&proof[0],ptr->txprooflen);
}
//fprintf(stderr,"gettxproof slen.%d\n",(int32_t)(sizeof(*ptr) - sizeof(ptr->tx) - sizeof(ptr->txproof) + ptr->txlen + ptr->txprooflen));
} }
//fprintf(stderr,"gettxproof slen.%d\n",(int32_t)(sizeof(*ptr) - sizeof(ptr->tx) - sizeof(ptr->txproof) + ptr->txlen + ptr->txprooflen));
} }
} }
ptr->unspentvalue = CCgettxout(txid,vout,1,1);
} }
ptr->unspentvalue = CCgettxout(txid,vout,1,1);
return(sizeof(*ptr) - sizeof(ptr->tx) - sizeof(ptr->txproof) + ptr->txlen + ptr->txprooflen); return(sizeof(*ptr) - sizeof(ptr->tx) - sizeof(ptr->txproof) + ptr->txlen + ptr->txprooflen);
} }
@@ -579,7 +640,7 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
iguana_rwnum(0,&request[len-8],sizeof(skipcount),&skipcount); iguana_rwnum(0,&request[len-8],sizeof(skipcount),&skipcount);
iguana_rwnum(0,&request[len-4],sizeof(filter),&filter); iguana_rwnum(0,&request[len-4],sizeof(filter),&filter);
} }
if ( isCC != 0 ) if ( 0 && isCC != 0 )
fprintf(stderr,"utxos %s isCC.%d skipcount.%d filter.%x\n",coinaddr,isCC,skipcount,filter); fprintf(stderr,"utxos %s isCC.%d skipcount.%d filter.%x\n",coinaddr,isCC,skipcount,filter);
memset(&U,0,sizeof(U)); memset(&U,0,sizeof(U));
if ( (slen= NSPV_getaddressutxos(&U,coinaddr,isCC,skipcount,filter)) > 0 ) if ( (slen= NSPV_getaddressutxos(&U,coinaddr,isCC,skipcount,filter)) > 0 )
@@ -619,7 +680,7 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
iguana_rwnum(0,&request[len-8],sizeof(skipcount),&skipcount); iguana_rwnum(0,&request[len-8],sizeof(skipcount),&skipcount);
iguana_rwnum(0,&request[len-4],sizeof(filter),&filter); iguana_rwnum(0,&request[len-4],sizeof(filter),&filter);
} }
//if ( isCC != 0 ) if ( 0 && isCC != 0 )
fprintf(stderr,"txids %s isCC.%d skipcount.%d filter.%d\n",coinaddr,isCC,skipcount,filter); fprintf(stderr,"txids %s isCC.%d skipcount.%d filter.%d\n",coinaddr,isCC,skipcount,filter);
memset(&T,0,sizeof(T)); memset(&T,0,sizeof(T));
if ( (slen= NSPV_getaddresstxids(&T,coinaddr,isCC,skipcount,filter)) > 0 ) if ( (slen= NSPV_getaddresstxids(&T,coinaddr,isCC,skipcount,filter)) > 0 )

View File

@@ -214,7 +214,7 @@ void komodo_nSPVresp(CNode *pfrom,std::vector<uint8_t> response) // received a r
CNode *NSPV_req(CNode *pnode,uint8_t *msg,int32_t len,uint64_t mask,int32_t ind) CNode *NSPV_req(CNode *pnode,uint8_t *msg,int32_t len,uint64_t mask,int32_t ind)
{ {
int32_t n,flag = 0; CNode *pnodes[64]; uint32_t timestamp = (uint32_t)time(NULL); int32_t n,flag = 0; CNode *pnodes[64]; uint32_t timestamp = (uint32_t)time(NULL);
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
return(0); return(0);
if ( pnode == 0 ) if ( pnode == 0 )
{ {
@@ -243,7 +243,7 @@ CNode *NSPV_req(CNode *pnode,uint8_t *msg,int32_t len,uint64_t mask,int32_t ind)
std::vector<uint8_t> request; std::vector<uint8_t> request;
request.resize(len); request.resize(len);
memcpy(&request[0],msg,len); memcpy(&request[0],msg,len);
if ( (0) && KOMODO_NSPV > 0 ) if ( (0) && KOMODO_NSPV_SUPERLITE )
fprintf(stderr,"pushmessage [%d] len.%d\n",msg[0],len); fprintf(stderr,"pushmessage [%d] len.%d\n",msg[0],len);
pnode->PushMessage("getnSPV",request); pnode->PushMessage("getnSPV",request);
pnode->prevtimes[ind] = timestamp; pnode->prevtimes[ind] = timestamp;
@@ -279,7 +279,7 @@ void komodo_nSPV(CNode *pto) // polling loop from SendMessages
return; return;
if ( pto->prevtimes[NSPV_INFO>>1] > timestamp ) if ( pto->prevtimes[NSPV_INFO>>1] > timestamp )
pto->prevtimes[NSPV_INFO>>1] = 0; pto->prevtimes[NSPV_INFO>>1] = 0;
if ( KOMODO_NSPV > 0 ) if ( KOMODO_NSPV_SUPERLITE )
{ {
if ( timestamp > NSPV_lastinfo + ASSETCHAINS_BLOCKTIME/2 && timestamp > pto->prevtimes[NSPV_INFO>>1] + 2*ASSETCHAINS_BLOCKTIME/3 ) if ( timestamp > NSPV_lastinfo + ASSETCHAINS_BLOCKTIME/2 && timestamp > pto->prevtimes[NSPV_INFO>>1] + 2*ASSETCHAINS_BLOCKTIME/3 )
{ {
@@ -355,7 +355,7 @@ UniValue NSPV_getinfo_json(struct NSPV_inforesp *ptr)
{ {
UniValue result(UniValue::VOBJ); int32_t expiration; uint32_t timestamp = (uint32_t)time(NULL); UniValue result(UniValue::VOBJ); int32_t expiration; uint32_t timestamp = (uint32_t)time(NULL);
result.push_back(Pair("result","success")); result.push_back(Pair("result","success"));
result.push_back(Pair("nSPV",KOMODO_NSPV!=0?"superlite":"fullnode")); result.push_back(Pair("nSPV",KOMODO_NSPV==-1?"disabled":(KOMODO_NSPV_SUPERLITE?"superlite":"fullnode")));
if ( NSPV_address.size() != 0 ) if ( NSPV_address.size() != 0 )
{ {
result.push_back(Pair("address",NSPV_address)); result.push_back(Pair("address",NSPV_address));
@@ -537,7 +537,7 @@ UniValue NSPV_login(char *wifstr)
result.push_back(Pair("address",NSPV_address)); result.push_back(Pair("address",NSPV_address));
result.push_back(Pair("pubkey",HexStr(pubkey))); result.push_back(Pair("pubkey",HexStr(pubkey)));
strcpy(NSPV_pubkeystr,HexStr(pubkey).c_str()); strcpy(NSPV_pubkeystr,HexStr(pubkey).c_str());
if ( KOMODO_NSPV > 0 ) if ( KOMODO_NSPV_SUPERLITE )
decode_hex(NOTARY_PUBKEY33,33,NSPV_pubkeystr); decode_hex(NOTARY_PUBKEY33,33,NSPV_pubkeystr);
result.push_back(Pair("wifprefix",(int64_t)data[0])); result.push_back(Pair("wifprefix",(int64_t)data[0]));
result.push_back(Pair("compressed",(int64_t)(data[len-5] == 1))); result.push_back(Pair("compressed",(int64_t)(data[len-5] == 1)));
@@ -659,6 +659,45 @@ UniValue NSPV_addresstxids(char *coinaddr,int32_t CCflag,int32_t skipcount,int32
return(result); return(result);
} }
UniValue NSPV_ccaddresstxids(char *coinaddr,int32_t CCflag,int32_t skipcount,uint256 filtertxid,uint8_t evalcode, uint8_t func)
{
UniValue result(UniValue::VOBJ); uint8_t msg[512],funcid=NSPV_CC_TXIDS; char zeroes[64]; int32_t i,iter,slen,len = 0,vout;
NSPV_mempoolresp_purge(&NSPV_mempoolresult);
memset(zeroes,0,sizeof(zeroes));
if ( coinaddr == 0 )
coinaddr = zeroes;
if ( coinaddr[0] != 0 && bitcoin_base58decode(msg,coinaddr) != 25 )
{
result.push_back(Pair("result","error"));
result.push_back(Pair("error","invalid address"));
return(result);
}
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);
slen = (int32_t)strlen(coinaddr);
msg[len++] = slen;
memcpy(&msg[len],coinaddr,slen), len += slen;
fprintf(stderr,"(%s) func.%d CC.%d %s skipcount.%d len.%d\n",coinaddr,NSPV_CC_TXIDS,CCflag,filtertxid.GetHex().c_str(),skipcount,len);
for (iter=0; iter<3; iter++)
if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 )
{
for (i=0; i<NSPV_POLLITERS; i++)
{
usleep(NSPV_POLLMICROS);
if ( NSPV_mempoolresult.nodeheight >= NSPV_inforesult.height && strcmp(coinaddr,NSPV_mempoolresult.coinaddr) == 0 && CCflag == NSPV_mempoolresult.CCflag && filtertxid == NSPV_mempoolresult.txid && vout == NSPV_mempoolresult.vout && funcid == NSPV_mempoolresult.funcid )
return(NSPV_mempoolresp_json(&NSPV_mempoolresult));
}
} else sleep(1);
result.push_back(Pair("result","error"));
result.push_back(Pair("error","no txid result"));
result.push_back(Pair("lastpeer",NSPV_lastpeer));
return(result);
}
UniValue NSPV_mempooltxids(char *coinaddr,int32_t CCflag,uint8_t funcid,uint256 txid,int32_t vout) UniValue NSPV_mempooltxids(char *coinaddr,int32_t CCflag,uint8_t funcid,uint256 txid,int32_t vout)
{ {
UniValue result(UniValue::VOBJ); uint8_t msg[512]; char zeroes[64]; int32_t i,iter,slen,len = 0; UniValue result(UniValue::VOBJ); uint8_t msg[512]; char zeroes[64]; int32_t i,iter,slen,len = 0;

View File

@@ -452,12 +452,12 @@ int64_t NSPV_AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total
mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID; mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID;
mtx.nVersion = SAPLING_TX_VERSION; mtx.nVersion = SAPLING_TX_VERSION;
Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG);
if ( strcmp(ptr->U.coinaddr,coinaddr) != 0 ) // if ( strcmp(ptr->U.coinaddr,coinaddr) != 0 )
{ // {
NSPV_addressutxos(coinaddr,CCflag,0,0); NSPV_addressutxos(coinaddr,CCflag,0,0);
NSPV_utxosresp_purge(&ptr->U); NSPV_utxosresp_purge(&ptr->U);
NSPV_utxosresp_copy(&ptr->U,&NSPV_utxosresult); NSPV_utxosresp_copy(&ptr->U,&NSPV_utxosresult);
} // }
fprintf(stderr,"%s numutxos.%d\n",ptr->U.coinaddr,ptr->U.numutxos); fprintf(stderr,"%s numutxos.%d\n",ptr->U.coinaddr,ptr->U.numutxos);
memset(ptr->used,0,sizeof(ptr->used)); memset(ptr->used,0,sizeof(ptr->used));
return(NSPV_addinputs(ptr->used,mtx,total,maxinputs,ptr->U.utxos,ptr->U.numutxos)); return(NSPV_addinputs(ptr->used,mtx,total,maxinputs,ptr->U.utxos,ptr->U.numutxos));
@@ -526,4 +526,10 @@ void NSPV_CCtxids(std::vector<std::pair<CAddressIndexKey, CAmount> > &txids,char
NSPV_txids2CCtxids(&NSPV_txidsresult,txids); NSPV_txids2CCtxids(&NSPV_txidsresult,txids);
} }
void NSPV_CCtxids(std::vector<uint256> &txids,char *coinaddr,bool ccflag, uint8_t evalcode,uint256 filtertxid, uint8_t func)
{
NSPV_ccaddresstxids(coinaddr,ccflag,0,filtertxid,evalcode,func);
for(int i=0;i<NSPV_mempoolresult.numtxids;i++) txids.push_back(NSPV_mempoolresult.txids[i]);
}
#endif // KOMODO_NSPVWALLET_H #endif // KOMODO_NSPVWALLET_H

View File

@@ -339,33 +339,44 @@ int32_t komodo_prevMoMheight()
int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp) int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp)
{ {
char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp;
*prevMoMheightp = 0;
memset(hashp,0,sizeof(*hashp));
memset(txidp,0,sizeof(*txidp));
if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) if ( (sp= komodo_stateptr(symbol,dest)) != 0 )
{ {
*hashp = sp->NOTARIZED_HASH; CBlockIndex *pindex;
*txidp = sp->NOTARIZED_DESTTXID; if ( (pindex= komodo_blockindex(sp->NOTARIZED_HASH)) == 0 || pindex->GetHeight() < 0 )
*prevMoMheightp = komodo_prevMoMheight(); {
//fprintf(stderr,"found orphaned notarization at ht.%d pindex.%p\n",sp->NOTARIZED_HEIGHT,(void *)pindex);
memset(&sp->NOTARIZED_HASH,0,sizeof(sp->NOTARIZED_HASH));
memset(&sp->NOTARIZED_DESTTXID,0,sizeof(sp->NOTARIZED_DESTTXID));
sp->NOTARIZED_HEIGHT = 0;
}
else
{
*hashp = sp->NOTARIZED_HASH;
*txidp = sp->NOTARIZED_DESTTXID;
*prevMoMheightp = komodo_prevMoMheight();
}
return(sp->NOTARIZED_HEIGHT); return(sp->NOTARIZED_HEIGHT);
} } else return(0);
else
{
*prevMoMheightp = 0;
memset(hashp,0,sizeof(*hashp));
memset(txidp,0,sizeof(*txidp));
return(0);
}
} }
int32_t komodo_dpowconfs(int32_t txheight,int32_t numconfs) int32_t komodo_dpowconfs(int32_t txheight,int32_t numconfs)
{ {
static int32_t hadnotarization;
char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp; char symbol[KOMODO_ASSETCHAIN_MAXLEN],dest[KOMODO_ASSETCHAIN_MAXLEN]; struct komodo_state *sp;
if ( KOMODO_DPOWCONFS != 0 && txheight > 0 && numconfs > 0 && (sp= komodo_stateptr(symbol,dest)) != 0 ) if ( KOMODO_DPOWCONFS != 0 && txheight > 0 && numconfs > 0 && (sp= komodo_stateptr(symbol,dest)) != 0 )
{ {
if ( sp->NOTARIZED_HEIGHT > 0 ) if ( sp->NOTARIZED_HEIGHT > 0 )
{ {
hadnotarization = 1;
if ( txheight < sp->NOTARIZED_HEIGHT ) if ( txheight < sp->NOTARIZED_HEIGHT )
return(numconfs); return(numconfs);
else return(1); else return(1);
} }
else if ( hadnotarization != 0 )
return(1);
} }
return(numconfs); return(numconfs);
} }

View File

@@ -2080,8 +2080,6 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
} }
} }
SyncWithWallets(tx, NULL);
return true; return true;
} }
@@ -2227,7 +2225,7 @@ bool myAddtomempool(CTransaction &tx, CValidationState *pstate, bool fSkipExpiry
bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock) bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock)
{ {
memset(&hashBlock,0,sizeof(hashBlock)); memset(&hashBlock,0,sizeof(hashBlock));
if ( KOMODO_NSPV > 0 ) if ( KOMODO_NSPV_SUPERLITE )
{ {
int64_t rewardsum = 0; int32_t i,retval,txheight,currentheight,height=0,vout = 0; int64_t rewardsum = 0; int32_t i,retval,txheight,currentheight,height=0,vout = 0;
for (i=0; i<NSPV_U.U.numutxos; i++) for (i=0; i<NSPV_U.U.numutxos; i++)
@@ -2281,7 +2279,7 @@ bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlo
bool NSPV_myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, int32_t &txheight, int32_t &currentheight) bool NSPV_myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, int32_t &txheight, int32_t &currentheight)
{ {
memset(&hashBlock,0,sizeof(hashBlock)); memset(&hashBlock,0,sizeof(hashBlock));
if ( KOMODO_NSPV > 0 ) if ( KOMODO_NSPV_SUPERLITE )
{ {
int64_t rewardsum = 0; int32_t i,retval,height=0,vout = 0; int64_t rewardsum = 0; int32_t i,retval,height=0,vout = 0;
for (i=0; i<NSPV_U.U.numutxos; i++) for (i=0; i<NSPV_U.U.numutxos; i++)
@@ -3427,7 +3425,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
{ {
CDiskBlockPos blockPos; CDiskBlockPos blockPos;
const CChainParams& chainparams = Params(); const CChainParams& chainparams = Params();
if ( KOMODO_NSPV > 0 ) if ( KOMODO_NSPV_SUPERLITE )
return(true); return(true);
if ( KOMODO_STOPAT != 0 && pindex->GetHeight() > KOMODO_STOPAT ) if ( KOMODO_STOPAT != 0 && pindex->GetHeight() > KOMODO_STOPAT )
return(false); return(false);
@@ -4011,7 +4009,7 @@ bool static FlushStateToDisk(CValidationState &state, FlushStateMode mode) {
void FlushStateToDisk() { void FlushStateToDisk() {
CValidationState state; CValidationState state;
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
FlushStateToDisk(state, FLUSH_STATE_ALWAYS); FlushStateToDisk(state, FLUSH_STATE_ALWAYS);
} }
@@ -4162,7 +4160,7 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) {
if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block,pindexDelete->GetHeight(),true) != 0))) if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block,pindexDelete->GetHeight(),true) != 0)))
{ {
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
if ( !GetBoolArg("-disablewallet", false) && KOMODO_NSPV <= 0 ) if ( !GetBoolArg("-disablewallet", false) && KOMODO_NSPV_FULLNODE )
pwalletMain->EraseFromWallet(tx.GetHash()); pwalletMain->EraseFromWallet(tx.GetHash());
#endif #endif
} }
@@ -4267,7 +4265,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
// Get the current commitment tree // Get the current commitment tree
SproutMerkleTree oldSproutTree; SproutMerkleTree oldSproutTree;
SaplingMerkleTree oldSaplingTree; SaplingMerkleTree oldSaplingTree;
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
{ {
assert(pcoinsTip->GetSproutAnchorAt(pcoinsTip->GetBestAnchor(SPROUT), oldSproutTree)); assert(pcoinsTip->GetSproutAnchorAt(pcoinsTip->GetBestAnchor(SPROUT), oldSproutTree));
assert(pcoinsTip->GetSaplingAnchorAt(pcoinsTip->GetBestAnchor(SAPLING), oldSaplingTree)); assert(pcoinsTip->GetSaplingAnchorAt(pcoinsTip->GetBestAnchor(SAPLING), oldSaplingTree));
@@ -4296,13 +4294,13 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
mapBlockSource.erase(pindexNew->GetBlockHash()); mapBlockSource.erase(pindexNew->GetBlockHash());
nTime3 = GetTimeMicros(); nTimeConnectTotal += nTime3 - nTime2; nTime3 = GetTimeMicros(); nTimeConnectTotal += nTime3 - nTime2;
LogPrint("bench", " - Connect total: %.2fms [%.2fs]\n", (nTime3 - nTime2) * 0.001, nTimeConnectTotal * 0.000001); LogPrint("bench", " - Connect total: %.2fms [%.2fs]\n", (nTime3 - nTime2) * 0.001, nTimeConnectTotal * 0.000001);
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
assert(view.Flush()); assert(view.Flush());
} }
int64_t nTime4 = GetTimeMicros(); nTimeFlush += nTime4 - nTime3; int64_t nTime4 = GetTimeMicros(); nTimeFlush += nTime4 - nTime3;
LogPrint("bench", " - Flush: %.2fms [%.2fs]\n", (nTime4 - nTime3) * 0.001, nTimeFlush * 0.000001); LogPrint("bench", " - Flush: %.2fms [%.2fs]\n", (nTime4 - nTime3) * 0.001, nTimeFlush * 0.000001);
// Write the chain state to disk, if necessary. // Write the chain state to disk, if necessary.
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
{ {
if (!FlushStateToDisk(state, FLUSH_STATE_IF_NEEDED)) if (!FlushStateToDisk(state, FLUSH_STATE_IF_NEEDED))
return false; return false;
@@ -4318,7 +4316,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
// Update chainActive & related variables. // Update chainActive & related variables.
UpdateTip(pindexNew); UpdateTip(pindexNew);
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
{ {
// Tell wallet about transactions that went from mempool // Tell wallet about transactions that went from mempool
// to conflicted: // to conflicted:
@@ -4346,7 +4344,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
komodo_broadcast(pblock,8); komodo_broadcast(pblock,8);
else if ( ASSETCHAINS_SYMBOL[0] != 0 ) else if ( ASSETCHAINS_SYMBOL[0] != 0 )
komodo_broadcast(pblock,4);*/ komodo_broadcast(pblock,4);*/
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
{ {
if ( ASSETCHAINS_CBOPRET != 0 ) if ( ASSETCHAINS_CBOPRET != 0 )
komodo_pricesupdate(pindexNew->GetHeight(),pblock); komodo_pricesupdate(pindexNew->GetHeight(),pblock);
@@ -4452,8 +4450,8 @@ static bool ActivateBestChainStep(bool fSkipdpow, CValidationState &state, CBloc
notarizedht = komodo_notarized_height(&prevMoMheight,&notarizedhash,&txid); notarizedht = komodo_notarized_height(&prevMoMheight,&notarizedhash,&txid);
if ( !fSkipdpow && pindexFork != 0 && pindexOldTip->GetHeight() > notarizedht && pindexFork->GetHeight() < notarizedht ) if ( !fSkipdpow && pindexFork != 0 && pindexOldTip->GetHeight() > notarizedht && pindexFork->GetHeight() < notarizedht )
{ {
fprintf(stderr,"pindexOldTip->GetHeight().%d > notarizedht %d && pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->GetHeight(),notarizedht,(int32_t)pindexOldTip->GetHeight(),notarizedht); fprintf(stderr,"pindexOldTip->GetHeight().%d > notarizedht %d && pindexFork->GetHeight().%d is < notarizedht %d, so ignore it\n",(int32_t)pindexOldTip->GetHeight(),notarizedht,(int32_t)pindexFork->GetHeight(),notarizedht);
return state.DoS(100, error("ActivateBestChainStep(): pindexOldTip->GetHeight().%d > notarizedht %d && pindexFork->GetHeight().%d is < notarizedht %d, so ignore it",(int32_t)pindexFork->GetHeight(),notarizedht,(int32_t)pindexOldTip->GetHeight(),notarizedht), return state.DoS(100, error("ActivateBestChainStep(): pindexOldTip->GetHeight().%d > notarizedht %d && pindexFork->GetHeight().%d is < notarizedht %d, so ignore it",(int32_t)pindexOldTip->GetHeight(),notarizedht,(int32_t)pindexFork->GetHeight(),notarizedht),
REJECT_INVALID, "past-notarized-height"); REJECT_INVALID, "past-notarized-height");
} }
// - On ChainDB initialization, pindexOldTip will be null, so there are no removable blocks. // - On ChainDB initialization, pindexOldTip will be null, so there are no removable blocks.
@@ -6568,7 +6566,7 @@ bool InitBlockIndex() {
if (!ActivateBestChain(true, state, &block)) if (!ActivateBestChain(true, state, &block))
return error("LoadBlockIndex(): genesis block cannot be activated"); return error("LoadBlockIndex(): genesis block cannot be activated");
// Force a chainstate write so that when we VerifyDB in a moment, it doesn't check stale data // Force a chainstate write so that when we VerifyDB in a moment, it doesn't check stale data
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
return FlushStateToDisk(state, FLUSH_STATE_ALWAYS); return FlushStateToDisk(state, FLUSH_STATE_ALWAYS);
else return(true); else return(true);
} catch (const std::runtime_error& e) { } catch (const std::runtime_error& e) {
@@ -7128,7 +7126,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
{ {
const CChainParams& chainparams = Params(); const CChainParams& chainparams = Params();
LogPrint("net", "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->id); LogPrint("net", "received: %s (%u bytes) peer=%d\n", SanitizeString(strCommand), vRecv.size(), pfrom->id);
//if ( KOMODO_NSPV > 0 ) //if ( KOMODO_NSPV_SUPERLITE )
//if ( strCommand != "version" && strCommand != "verack" ) //if ( strCommand != "version" && strCommand != "verack" )
// fprintf(stderr, "recv: %s (%u bytes) peer=%d\n", SanitizeString(strCommand).c_str(), (int32_t)vRecv.size(), (int32_t)pfrom->GetId()); // fprintf(stderr, "recv: %s (%u bytes) peer=%d\n", SanitizeString(strCommand).c_str(), (int32_t)vRecv.size(), (int32_t)pfrom->GetId());
if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0) if (mapArgs.count("-dropmessagestest") && GetRand(atoi(mapArgs["-dropmessagestest"])) == 0)
@@ -7303,7 +7301,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
{ {
pfrom->SetRecvVersion(min(pfrom->nVersion, PROTOCOL_VERSION)); pfrom->SetRecvVersion(min(pfrom->nVersion, PROTOCOL_VERSION));
if ( KOMODO_NSPV > 0 ) if ( KOMODO_NSPV_SUPERLITE )
{ {
if ( (pfrom->nServices & NODE_NSPV) == 0 ) if ( (pfrom->nServices & NODE_NSPV) == 0 )
{ {
@@ -7513,7 +7511,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
} }
else if (strCommand == "nSPV") else if (strCommand == "nSPV")
{ {
if ( KOMODO_NSPV > 0 ) if ( KOMODO_NSPV_SUPERLITE )
{ {
std::vector<uint8_t> payload; std::vector<uint8_t> payload;
vRecv >> payload; vRecv >> payload;
@@ -7521,7 +7519,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
} }
return(true); return(true);
} }
else if ( KOMODO_NSPV > 0 ) else if ( KOMODO_NSPV_SUPERLITE )
return(true); return(true);
else if (strCommand == "inv") else if (strCommand == "inv")
{ {
@@ -8311,7 +8309,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
} }
state.fShouldBan = false; state.fShouldBan = false;
} }
if ( KOMODO_NSPV > 0 ) if ( KOMODO_NSPV_SUPERLITE )
{ {
komodo_nSPV(pto); komodo_nSPV(pto);
return(true); return(true);
@@ -8522,7 +8520,7 @@ extern "C" const char* getDataDir()
CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Params& consensusParams, int nHeight) CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Params& consensusParams, int nHeight)
{ {
CMutableTransaction mtx; CMutableTransaction mtx;
if ( KOMODO_NSPV > 0 ) if ( KOMODO_NSPV_SUPERLITE )
{ {
mtx.fOverwintered = true; mtx.fOverwintered = true;
mtx.nExpiryHeight = 0; mtx.nExpiryHeight = 0;

View File

@@ -445,6 +445,13 @@ void CNode::CloseSocketDisconnect()
} }
extern int32_t KOMODO_NSPV; extern int32_t KOMODO_NSPV;
#ifndef KOMODO_NSPV_FULLNODE
#define KOMODO_NSPV_FULLNODE (KOMODO_NSPV <= 0)
#endif // !KOMODO_NSPV_FULLNODE
#ifndef KOMODO_NSPV_SUPERLITE
#define KOMODO_NSPV_SUPERLITE (KOMODO_NSPV > 0)
#endif // !KOMODO_NSPV_SUPERLITE
void CNode::PushVersion() void CNode::PushVersion()
{ {
@@ -1843,7 +1850,7 @@ bool StopNode()
for (int i=0; i<MAX_OUTBOUND_CONNECTIONS; i++) for (int i=0; i<MAX_OUTBOUND_CONNECTIONS; i++)
semOutbound->post(); semOutbound->post();
if (KOMODO_NSPV <= 0 && fAddressesInitialized) if (KOMODO_NSPV_FULLNODE && fAddressesInitialized)
{ {
DumpAddresses(); DumpAddresses();
fAddressesInitialized = false; fAddressesInitialized = false;

View File

@@ -396,7 +396,7 @@ bool NSPV_inmempool(uint256 txid);
bool myIsutxo_spentinmempool(uint256 &spenttxid,int32_t &spentvini,uint256 txid,int32_t vout) bool myIsutxo_spentinmempool(uint256 &spenttxid,int32_t &spentvini,uint256 txid,int32_t vout)
{ {
int32_t vini = 0; int32_t vini = 0;
if ( KOMODO_NSPV > 0 ) if ( KOMODO_NSPV_SUPERLITE )
return(NSPV_spentinmempool(spenttxid,spentvini,txid,vout)); return(NSPV_spentinmempool(spenttxid,spentvini,txid,vout));
BOOST_FOREACH(const CTxMemPoolEntry &e,mempool.mapTx) BOOST_FOREACH(const CTxMemPoolEntry &e,mempool.mapTx)
{ {
@@ -420,7 +420,7 @@ bool myIsutxo_spentinmempool(uint256 &spenttxid,int32_t &spentvini,uint256 txid,
bool mytxid_inmempool(uint256 txid) bool mytxid_inmempool(uint256 txid)
{ {
if ( KOMODO_NSPV > 0 ) if ( KOMODO_NSPV_SUPERLITE )
{ {
} }
@@ -1906,6 +1906,10 @@ UniValue mempoolInfoToJSON()
ret.push_back(Pair("bytes", (int64_t) mempool.GetTotalTxSize())); ret.push_back(Pair("bytes", (int64_t) mempool.GetTotalTxSize()));
ret.push_back(Pair("usage", (int64_t) mempool.DynamicMemoryUsage())); ret.push_back(Pair("usage", (int64_t) mempool.DynamicMemoryUsage()));
if (Params().NetworkIDString() == "regtest") {
ret.push_back(Pair("fullyNotified", mempool.IsFullyNotified()));
}
return ret; return ret;
} }

View File

@@ -884,8 +884,8 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
result.push_back(Pair("origtarget", hashTarget.GetHex())); result.push_back(Pair("origtarget", hashTarget.GetHex()));
} }
/*else if ( ASSETCHAINS_ADAPTIVEPOW > 0 ) /*else if ( ASSETCHAINS_ADAPTIVEPOW > 0 )
result.push_back(Pair("target",komodo_adaptivepow_target((int32_t)(pindexPrev->GetHeight()+1),hashTarget,pblock->nTime).GetHex())); result.push_back(Pair("target",komodo_adaptivepow_target((int32_t)(pindexPrev->GetHeight()+1),hashTarget,pblock->nTime).GetHex()));*/
else*/ else
result.push_back(Pair("target", hashTarget.GetHex())); result.push_back(Pair("target", hashTarget.GetHex()));
result.push_back(Pair("mintime", (int64_t)pindexPrev->GetMedianTimePast()+1)); result.push_back(Pair("mintime", (int64_t)pindexPrev->GetMedianTimePast()+1));
result.push_back(Pair("mutable", aMutable)); result.push_back(Pair("mutable", aMutable));

View File

@@ -243,7 +243,7 @@ UniValue getinfo(const UniValue& params, bool fHelp)
obj.push_back(Pair("prevMoMheight", prevMoMheight)); obj.push_back(Pair("prevMoMheight", prevMoMheight));
obj.push_back(Pair("notarizedhash", notarized_hash.ToString())); obj.push_back(Pair("notarizedhash", notarized_hash.ToString()));
obj.push_back(Pair("notarizedtxid", notarized_desttxid.ToString())); obj.push_back(Pair("notarizedtxid", notarized_desttxid.ToString()));
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
{ {
txid_height = notarizedtxid_height(ASSETCHAINS_SYMBOL[0] != 0 ? (char *)"KMD" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height); txid_height = notarizedtxid_height(ASSETCHAINS_SYMBOL[0] != 0 ? (char *)"KMD" : (char *)"BTC",(char *)notarized_desttxid.ToString().c_str(),&kmdnotarized_height);
if ( txid_height > 0 ) if ( txid_height > 0 )

View File

@@ -374,7 +374,7 @@ void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& entry)
const CTxOut& txout = tx.vout[i]; const CTxOut& txout = tx.vout[i];
UniValue out(UniValue::VOBJ); UniValue out(UniValue::VOBJ);
out.push_back(Pair("value", ValueFromAmount(txout.nValue))); out.push_back(Pair("value", ValueFromAmount(txout.nValue)));
if ( KOMODO_NSPV <= 0 && ASSETCHAINS_SYMBOL[0] == 0 && tx.nLockTime >= 500000000 && (tipindex= chainActive.LastTip()) != 0 ) if ( KOMODO_NSPV_FULLNODE && ASSETCHAINS_SYMBOL[0] == 0 && tx.nLockTime >= 500000000 && (tipindex= chainActive.LastTip()) != 0 )
{ {
int64_t interest; int32_t txheight; uint32_t locktime; int64_t interest; int32_t txheight; uint32_t locktime;
interest = komodo_accrued_interest(&txheight,&locktime,tx.GetHash(),i,0,txout.nValue,(int32_t)tipindex->GetHeight()); interest = komodo_accrued_interest(&txheight,&locktime,tx.GetHash(),i,0,txout.nValue,(int32_t)tipindex->GetHeight());
@@ -1366,7 +1366,7 @@ UniValue sendrawtransaction(const UniValue& params, bool fHelp)
bool fOverrideFees = false; bool fOverrideFees = false;
if (params.size() > 1) if (params.size() > 1)
fOverrideFees = params[1].get_bool(); fOverrideFees = params[1].get_bool();
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
{ {
CCoinsViewCache &view = *pcoinsTip; CCoinsViewCache &view = *pcoinsTip;
const CCoins* existingCoins = view.AccessCoins(hashTx); const CCoins* existingCoins = view.AccessCoins(hashTx);

View File

@@ -37,6 +37,13 @@ typedef vector<unsigned char> valtype;
extern uint8_t ASSETCHAINS_TXPOW; extern uint8_t ASSETCHAINS_TXPOW;
extern char NSPV_wifstr[],NSPV_pubkeystr[]; extern char NSPV_wifstr[],NSPV_pubkeystr[];
extern int32_t KOMODO_NSPV; extern int32_t KOMODO_NSPV;
#ifndef KOMODO_NSPV_FULLNODE
#define KOMODO_NSPV_FULLNODE (KOMODO_NSPV <= 0)
#endif // !KOMODO_NSPV_FULLNODE
#ifndef KOMODO_NSPV_SUPERLITE
#define KOMODO_NSPV_SUPERLITE (KOMODO_NSPV > 0)
#endif // !KOMODO_NSPV_SUPERLITE
uint256 SIG_TXHASH; uint256 SIG_TXHASH;
TransactionSignatureCreator::TransactionSignatureCreator(const CKeyStore* keystoreIn, const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, int nHashTypeIn) : BaseSignatureCreator(keystoreIn), txTo(txToIn), nIn(nInIn), nHashType(nHashTypeIn), amount(amountIn), checker(txTo, nIn, amountIn) {} TransactionSignatureCreator::TransactionSignatureCreator(const CKeyStore* keystoreIn, const CTransaction* txToIn, unsigned int nInIn, const CAmount& amountIn, int nHashTypeIn) : BaseSignatureCreator(keystoreIn), txTo(txToIn), nIn(nInIn), nHashType(nHashTypeIn), amount(amountIn), checker(txTo, nIn, amountIn) {}
@@ -53,7 +60,7 @@ bool TransactionSignatureCreator::CreateSig(std::vector<unsigned char>& vchSig,
} }
} }
SIG_TXHASH = hash; SIG_TXHASH = hash;
if ( KOMODO_NSPV > 0 ) if ( KOMODO_NSPV_SUPERLITE )
key = DecodeSecret(NSPV_wifstr); key = DecodeSecret(NSPV_wifstr);
else if (pprivKey) else if (pprivKey)
key = *pprivKey; key = *pprivKey;
@@ -74,7 +81,7 @@ bool TransactionSignatureCreator::CreateSig(std::vector<unsigned char>& vchSig,
return false; return false;
} }
vchSig = CCSigVec(cc); vchSig = CCSigVec(cc);
if ( KOMODO_NSPV > 0 ) if ( KOMODO_NSPV_SUPERLITE )
memset((uint8_t *)key.begin(),0,32); memset((uint8_t *)key.begin(),0,32);
return true; return true;
} }
@@ -100,7 +107,7 @@ bool TransactionSignatureCreator::CreateSig(std::vector<unsigned char>& vchSig,
} }
vchSig.push_back((unsigned char)nHashType); vchSig.push_back((unsigned char)nHashType);
if ( KOMODO_NSPV > 0 ) if ( KOMODO_NSPV_SUPERLITE )
memset((uint8_t *)key.begin(),0,32); memset((uint8_t *)key.begin(),0,32);
return true; return true;
} }
@@ -381,7 +388,7 @@ static bool SignStep(const BaseSignatureCreator& creator, const CScript& scriptP
} }
else else
{ {
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
{ {
CPubKey vch; CPubKey vch;
creator.KeyStore().GetPubKey(keyID, vch); creator.KeyStore().GetPubKey(keyID, vch);

View File

@@ -29,6 +29,7 @@
#include "timedata.h" #include "timedata.h"
#include "util.h" #include "util.h"
#include "utilmoneystr.h" #include "utilmoneystr.h"
#include "validationinterface.h"
#include "version.h" #include "version.h"
#define _COINBASE_MATURITY 100 #define _COINBASE_MATURITY 100
@@ -119,6 +120,8 @@ bool CTxMemPool::addUnchecked(const uint256& hash, const CTxMemPoolEntry &entry,
LOCK(cs); LOCK(cs);
mapTx.insert(entry); mapTx.insert(entry);
const CTransaction& tx = mapTx.find(hash)->GetTx(); const CTransaction& tx = mapTx.find(hash)->GetTx();
mapRecentlyAddedTx[tx.GetHash()] = &tx;
nRecentlyAddedSequence += 1;
if (!tx.IsCoinImport()) { if (!tx.IsCoinImport()) {
for (unsigned int i = 0; i < tx.vin.size(); i++) for (unsigned int i = 0; i < tx.vin.size(); i++)
{ {
@@ -365,6 +368,7 @@ void CTxMemPool::remove(const CTransaction &origTx, std::list<CTransaction>& rem
txToRemove.push_back(it->second.ptx->GetHash()); txToRemove.push_back(it->second.ptx->GetHash());
} }
} }
mapRecentlyAddedTx.erase(hash);
BOOST_FOREACH(const CTxIn& txin, tx.vin) BOOST_FOREACH(const CTxIn& txin, tx.vin)
mapNextTx.erase(txin.prevout); mapNextTx.erase(txin.prevout);
BOOST_FOREACH(const JSDescription& joinsplit, tx.vjoinsplit) { BOOST_FOREACH(const JSDescription& joinsplit, tx.vjoinsplit) {
@@ -838,6 +842,49 @@ bool CTxMemPool::nullifierExists(const uint256& nullifier, ShieldedType type) co
} }
} }
void CTxMemPool::NotifyRecentlyAdded()
{
uint64_t recentlyAddedSequence;
std::vector<CTransaction> txs;
{
LOCK(cs);
recentlyAddedSequence = nRecentlyAddedSequence;
for (const auto& kv : mapRecentlyAddedTx) {
txs.push_back(*(kv.second));
}
mapRecentlyAddedTx.clear();
}
// A race condition can occur here between these SyncWithWallets calls, and
// the ones triggered by block logic (in ConnectTip and DisconnectTip). It
// is harmless because calling SyncWithWallets(_, NULL) does not alter the
// wallet transaction's block information.
for (auto tx : txs) {
try {
SyncWithWallets(tx, NULL);
} catch (const boost::thread_interrupted&) {
throw;
} catch (const std::exception& e) {
PrintExceptionContinue(&e, "CTxMemPool::NotifyRecentlyAdded()");
} catch (...) {
PrintExceptionContinue(NULL, "CTxMemPool::NotifyRecentlyAdded()");
}
}
// Update the notified sequence number. We only need this in regtest mode,
// and should not lock on cs after calling SyncWithWallets otherwise.
if (Params().NetworkIDString() == "regtest") {
LOCK(cs);
nNotifiedSequence = recentlyAddedSequence;
}
}
bool CTxMemPool::IsFullyNotified() {
assert(Params().NetworkIDString() == "regtest");
LOCK(cs);
return nRecentlyAddedSequence == nNotifiedSequence;
}
CCoinsViewMemPool::CCoinsViewMemPool(CCoinsView *baseIn, CTxMemPool &mempoolIn) : CCoinsViewBacked(baseIn), mempool(mempoolIn) { } CCoinsViewMemPool::CCoinsViewMemPool(CCoinsView *baseIn, CTxMemPool &mempoolIn) : CCoinsViewBacked(baseIn), mempool(mempoolIn) { }
bool CCoinsViewMemPool::GetNullifier(const uint256 &nf, ShieldedType type) const bool CCoinsViewMemPool::GetNullifier(const uint256 &nf, ShieldedType type) const

View File

@@ -148,6 +148,10 @@ private:
uint64_t totalTxSize = 0; //! sum of all mempool tx' byte sizes uint64_t totalTxSize = 0; //! sum of all mempool tx' byte sizes
uint64_t cachedInnerUsage; //! sum of dynamic memory usage of all the map elements (NOT the maps themselves) uint64_t cachedInnerUsage; //! sum of dynamic memory usage of all the map elements (NOT the maps themselves)
std::map<uint256, const CTransaction*> mapRecentlyAddedTx;
uint64_t nRecentlyAddedSequence = 0;
uint64_t nNotifiedSequence = 0;
std::map<uint256, const CTransaction*> mapSproutNullifiers; std::map<uint256, const CTransaction*> mapSproutNullifiers;
std::map<uint256, const CTransaction*> mapSaplingNullifiers; std::map<uint256, const CTransaction*> mapSaplingNullifiers;
@@ -234,6 +238,9 @@ public:
bool nullifierExists(const uint256& nullifier, ShieldedType type) const; bool nullifierExists(const uint256& nullifier, ShieldedType type) const;
void NotifyRecentlyAdded();
bool IsFullyNotified();
unsigned long size() unsigned long size()
{ {
LOCK(cs); LOCK(cs);

View File

@@ -973,6 +973,13 @@ UniValue z_exportviewingkey(const UniValue& params, bool fHelp)
} }
extern int32_t KOMODO_NSPV; extern int32_t KOMODO_NSPV;
#ifndef KOMODO_NSPV_FULLNODE
#define KOMODO_NSPV_FULLNODE (KOMODO_NSPV <= 0)
#endif // !KOMODO_NSPV_FULLNODE
#ifndef KOMODO_NSPV_SUPERLITE
#define KOMODO_NSPV_SUPERLITE (KOMODO_NSPV > 0)
#endif // !KOMODO_NSPV_SUPERLITE
uint256 zeroid;
UniValue NSPV_getinfo_req(int32_t reqht); UniValue NSPV_getinfo_req(int32_t reqht);
UniValue NSPV_login(char *wifstr); UniValue NSPV_login(char *wifstr);
UniValue NSPV_logout(); UniValue NSPV_logout();
@@ -993,7 +1000,7 @@ UniValue nspv_getinfo(const UniValue& params, bool fHelp)
int32_t reqht = 0; int32_t reqht = 0;
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("nspv_getinfo [hdrheight]\n"); throw runtime_error("nspv_getinfo [hdrheight]\n");
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
throw runtime_error("-nSPV=1 must be set to use nspv\n"); throw runtime_error("-nSPV=1 must be set to use nspv\n");
if ( params.size() == 1 ) if ( params.size() == 1 )
reqht = atoi((char *)params[0].get_str().c_str()); reqht = atoi((char *)params[0].get_str().c_str());
@@ -1004,7 +1011,7 @@ UniValue nspv_logout(const UniValue& params, bool fHelp)
{ {
if ( fHelp || params.size() != 0 ) if ( fHelp || params.size() != 0 )
throw runtime_error("nspv_logout\n"); throw runtime_error("nspv_logout\n");
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
throw runtime_error("-nSPV=1 must be set to use nspv\n"); throw runtime_error("-nSPV=1 must be set to use nspv\n");
return(NSPV_logout()); return(NSPV_logout());
} }
@@ -1013,7 +1020,7 @@ UniValue nspv_login(const UniValue& params, bool fHelp)
{ {
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("nspv_login wif\n"); throw runtime_error("nspv_login wif\n");
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
throw runtime_error("-nSPV=1 must be set to use nspv\n"); throw runtime_error("-nSPV=1 must be set to use nspv\n");
return(NSPV_login((char *)params[0].get_str().c_str())); return(NSPV_login((char *)params[0].get_str().c_str()));
} }
@@ -1023,7 +1030,7 @@ UniValue nspv_listunspent(const UniValue& params, bool fHelp)
int32_t skipcount = 0,CCflag = 0; int32_t skipcount = 0,CCflag = 0;
if ( fHelp || params.size() > 3 ) if ( fHelp || params.size() > 3 )
throw runtime_error("nspv_listunspent [address [isCC [skipcount]]]\n"); throw runtime_error("nspv_listunspent [address [isCC [skipcount]]]\n");
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
throw runtime_error("-nSPV=1 must be set to use nspv\n"); throw runtime_error("-nSPV=1 must be set to use nspv\n");
if ( params.size() == 0 ) if ( params.size() == 0 )
{ {
@@ -1048,7 +1055,7 @@ UniValue nspv_mempool(const UniValue& params, bool fHelp)
memset(&txid,0,sizeof(txid)); memset(&txid,0,sizeof(txid));
if ( fHelp || params.size() > 5 ) if ( fHelp || params.size() > 5 )
throw runtime_error("nspv_mempool func(0 all, 1 address recv, 2 txid/vout spent, 3 txid inmempool) address isCC [txid vout]]]\n"); throw runtime_error("nspv_mempool func(0 all, 1 address recv, 2 txid/vout spent, 3 txid inmempool) address isCC [txid vout]]]\n");
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
throw runtime_error("-nSPV=1 must be set to use nspv\n"); throw runtime_error("-nSPV=1 must be set to use nspv\n");
funcid = atoi((char *)params[0].get_str().c_str()); funcid = atoi((char *)params[0].get_str().c_str());
coinaddr = (char *)params[1].get_str().c_str(); coinaddr = (char *)params[1].get_str().c_str();
@@ -1068,7 +1075,7 @@ UniValue nspv_listtransactions(const UniValue& params, bool fHelp)
int32_t skipcount = 0,CCflag = 0; int32_t skipcount = 0,CCflag = 0;
if ( fHelp || params.size() > 3 ) if ( fHelp || params.size() > 3 )
throw runtime_error("nspv_listtransactions [address [isCC [skipcount]]]\n"); throw runtime_error("nspv_listtransactions [address [isCC [skipcount]]]\n");
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
throw runtime_error("-nSPV=1 must be set to use nspv\n"); throw runtime_error("-nSPV=1 must be set to use nspv\n");
if ( params.size() == 0 ) if ( params.size() == 0 )
{ {
@@ -1093,7 +1100,7 @@ UniValue nspv_spentinfo(const UniValue& params, bool fHelp)
uint256 txid; int32_t vout; uint256 txid; int32_t vout;
if ( fHelp || params.size() != 2 ) if ( fHelp || params.size() != 2 )
throw runtime_error("nspv_spentinfo txid vout\n"); throw runtime_error("nspv_spentinfo txid vout\n");
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
throw runtime_error("-nSPV=1 must be set to use nspv\n"); throw runtime_error("-nSPV=1 must be set to use nspv\n");
txid = Parseuint256((char *)params[0].get_str().c_str()); txid = Parseuint256((char *)params[0].get_str().c_str());
vout = atoi((char *)params[1].get_str().c_str()); vout = atoi((char *)params[1].get_str().c_str());
@@ -1105,7 +1112,7 @@ UniValue nspv_notarizations(const UniValue& params, bool fHelp)
int32_t height; int32_t height;
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("nspv_notarizations height\n"); throw runtime_error("nspv_notarizations height\n");
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
throw runtime_error("-nSPV=1 must be set to use nspv\n"); throw runtime_error("-nSPV=1 must be set to use nspv\n");
height = atoi((char *)params[0].get_str().c_str()); height = atoi((char *)params[0].get_str().c_str());
return(NSPV_notarizations(height)); return(NSPV_notarizations(height));
@@ -1116,7 +1123,7 @@ UniValue nspv_hdrsproof(const UniValue& params, bool fHelp)
int32_t prevheight,nextheight; int32_t prevheight,nextheight;
if ( fHelp || params.size() != 2 ) if ( fHelp || params.size() != 2 )
throw runtime_error("nspv_hdrsproof prevheight nextheight\n"); throw runtime_error("nspv_hdrsproof prevheight nextheight\n");
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
throw runtime_error("-nSPV=1 must be set to use nspv\n"); throw runtime_error("-nSPV=1 must be set to use nspv\n");
prevheight = atoi((char *)params[0].get_str().c_str()); prevheight = atoi((char *)params[0].get_str().c_str());
nextheight = atoi((char *)params[1].get_str().c_str()); nextheight = atoi((char *)params[1].get_str().c_str());
@@ -1128,7 +1135,7 @@ UniValue nspv_txproof(const UniValue& params, bool fHelp)
uint256 txid; int32_t height; uint256 txid; int32_t height;
if ( fHelp || params.size() != 2 ) if ( fHelp || params.size() != 2 )
throw runtime_error("nspv_txproof txid height\n"); throw runtime_error("nspv_txproof txid height\n");
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
throw runtime_error("-nSPV=1 must be set to use nspv\n"); throw runtime_error("-nSPV=1 must be set to use nspv\n");
txid = Parseuint256((char *)params[0].get_str().c_str()); txid = Parseuint256((char *)params[0].get_str().c_str());
height = atoi((char *)params[1].get_str().c_str()); height = atoi((char *)params[1].get_str().c_str());
@@ -1140,7 +1147,7 @@ UniValue nspv_spend(const UniValue& params, bool fHelp)
uint64_t satoshis; uint64_t satoshis;
if ( fHelp || params.size() != 2 ) if ( fHelp || params.size() != 2 )
throw runtime_error("nspv_spend address amount\n"); throw runtime_error("nspv_spend address amount\n");
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
throw runtime_error("-nSPV=1 must be set to use nspv\n"); throw runtime_error("-nSPV=1 must be set to use nspv\n");
if ( NSPV_address.size() == 0 ) if ( NSPV_address.size() == 0 )
throw runtime_error("to nspv_send you need an active nspv_login\n"); throw runtime_error("to nspv_send you need an active nspv_login\n");
@@ -1155,7 +1162,7 @@ UniValue nspv_broadcast(const UniValue& params, bool fHelp)
{ {
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("nspv_broadcast hex\n"); throw runtime_error("nspv_broadcast hex\n");
if ( KOMODO_NSPV <= 0 ) if ( KOMODO_NSPV_FULLNODE )
throw runtime_error("-nSPV=1 must be set to use nspv\n"); throw runtime_error("-nSPV=1 must be set to use nspv\n");
return(NSPV_broadcast((char *)params[0].get_str().c_str())); return(NSPV_broadcast((char *)params[0].get_str().c_str()));
} }

View File

@@ -163,7 +163,7 @@ void OS_randombytes(unsigned char *x,long xlen);
UniValue getnewaddress(const UniValue& params, bool fHelp) UniValue getnewaddress(const UniValue& params, bool fHelp)
{ {
if ( KOMODO_NSPV <= 0 && !EnsureWalletIsAvailable(fHelp) ) if ( KOMODO_NSPV_FULLNODE && !EnsureWalletIsAvailable(fHelp) )
return NullUniValue; return NullUniValue;
if (fHelp || params.size() > 1) if (fHelp || params.size() > 1)
@@ -179,7 +179,7 @@ UniValue getnewaddress(const UniValue& params, bool fHelp)
+ HelpExampleRpc("getnewaddress", "") + HelpExampleRpc("getnewaddress", "")
); );
if ( KOMODO_NSPV > 0 ) if ( KOMODO_NSPV_SUPERLITE )
{ {
UniValue result(UniValue::VOBJ); uint8_t priv32[32]; UniValue result(UniValue::VOBJ); uint8_t priv32[32];
#ifndef __WIN32 #ifndef __WIN32
@@ -2975,7 +2975,7 @@ UniValue listunspent(const UniValue& params, bool fHelp)
uint64_t komodo_interestsum() uint64_t komodo_interestsum()
{ {
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
if ( ASSETCHAINS_SYMBOL[0] == 0 && GetBoolArg("-disablewallet", false) == 0 && KOMODO_NSPV <= 0 ) if ( ASSETCHAINS_SYMBOL[0] == 0 && GetBoolArg("-disablewallet", false) == 0 && KOMODO_NSPV_FULLNODE )
{ {
uint64_t interest,sum = 0; int32_t txheight; uint32_t locktime; uint64_t interest,sum = 0; int32_t txheight; uint32_t locktime;
vector<COutput> vecOutputs; vector<COutput> vecOutputs;
@@ -5673,7 +5673,7 @@ UniValue channelsaddress(const UniValue& params, bool fHelp)
cp = CCinit(&C,EVAL_CHANNELS); cp = CCinit(&C,EVAL_CHANNELS);
if ( fHelp || params.size() != 1 ) if ( fHelp || params.size() != 1 )
throw runtime_error("channelsaddress pubkey\n"); throw runtime_error("channelsaddress pubkey\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(cp->evalcode) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG); throw runtime_error(CC_REQUIREMENTS_MSG);
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
return(CCaddress(cp,(char *)"Channels",pubkey)); return(CCaddress(cp,(char *)"Channels",pubkey));
@@ -5684,8 +5684,6 @@ UniValue cclibaddress(const UniValue& params, bool fHelp)
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey; uint8_t evalcode = EVAL_FIRSTUSER; struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey; uint8_t evalcode = EVAL_FIRSTUSER;
if ( fHelp || params.size() > 2 ) if ( fHelp || params.size() > 2 )
throw runtime_error("cclibaddress [evalcode] [pubkey]\n"); throw runtime_error("cclibaddress [evalcode] [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() >= 1 ) if ( params.size() >= 1 )
{ {
evalcode = atoi(params[0].get_str().c_str()); evalcode = atoi(params[0].get_str().c_str());
@@ -5695,6 +5693,8 @@ UniValue cclibaddress(const UniValue& params, bool fHelp)
pubkey = ParseHex(params[1].get_str().c_str()); pubkey = ParseHex(params[1].get_str().c_str());
} }
cp = CCinit(&C,evalcode); cp = CCinit(&C,evalcode);
if ( ensure_CCrequirements(cp->evalcode) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG);
if ( cp == 0 ) if ( cp == 0 )
throw runtime_error("error creating *cp\n"); throw runtime_error("error creating *cp\n");
return(CCaddress(cp,(char *)"CClib",pubkey)); return(CCaddress(cp,(char *)"CClib",pubkey));
@@ -5871,7 +5871,7 @@ UniValue oraclesaddress(const UniValue& params, bool fHelp)
cp = CCinit(&C,EVAL_ORACLES); cp = CCinit(&C,EVAL_ORACLES);
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("oraclesaddress [pubkey]\n"); throw runtime_error("oraclesaddress [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(cp->evalcode) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 ) if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
@@ -5885,7 +5885,7 @@ UniValue pricesaddress(const UniValue& params, bool fHelp)
assetscp = CCinit(&C2,EVAL_PRICES); assetscp = CCinit(&C2,EVAL_PRICES);
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("pricesaddress [pubkey]\n"); throw runtime_error("pricesaddress [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(cp->evalcode) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 ) if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
@@ -5907,7 +5907,7 @@ UniValue pegsaddress(const UniValue& params, bool fHelp)
cp = CCinit(&C,EVAL_PEGS); cp = CCinit(&C,EVAL_PEGS);
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("pegssaddress [pubkey]\n"); throw runtime_error("pegssaddress [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(cp->evalcode) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 ) if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
@@ -5920,7 +5920,7 @@ UniValue marmaraaddress(const UniValue& params, bool fHelp)
cp = CCinit(&C,EVAL_MARMARA); cp = CCinit(&C,EVAL_MARMARA);
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("Marmaraaddress [pubkey]\n"); throw runtime_error("Marmaraaddress [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(cp->evalcode) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 ) if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
@@ -5933,7 +5933,7 @@ UniValue paymentsaddress(const UniValue& params, bool fHelp)
cp = CCinit(&C,EVAL_PAYMENTS); cp = CCinit(&C,EVAL_PAYMENTS);
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("paymentsaddress [pubkey]\n"); throw runtime_error("paymentsaddress [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(cp->evalcode) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 ) if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
@@ -5946,7 +5946,7 @@ UniValue gatewaysaddress(const UniValue& params, bool fHelp)
cp = CCinit(&C,EVAL_GATEWAYS); cp = CCinit(&C,EVAL_GATEWAYS);
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("gatewaysaddress [pubkey]\n"); throw runtime_error("gatewaysaddress [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(cp->evalcode) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 ) if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
@@ -5959,7 +5959,7 @@ UniValue heiraddress(const UniValue& params, bool fHelp)
cp = CCinit(&C,EVAL_HEIR); cp = CCinit(&C,EVAL_HEIR);
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("heiraddress pubkey\n"); throw runtime_error("heiraddress pubkey\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(cp->evalcode) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG); throw runtime_error(CC_REQUIREMENTS_MSG);
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
return(CCaddress(cp,(char *)"Heir",pubkey)); return(CCaddress(cp,(char *)"Heir",pubkey));
@@ -5971,7 +5971,7 @@ UniValue lottoaddress(const UniValue& params, bool fHelp)
cp = CCinit(&C,EVAL_LOTTO); cp = CCinit(&C,EVAL_LOTTO);
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("lottoaddress [pubkey]\n"); throw runtime_error("lottoaddress [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(cp->evalcode) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 ) if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
@@ -5984,7 +5984,7 @@ UniValue FSMaddress(const UniValue& params, bool fHelp)
cp = CCinit(&C,EVAL_FSM); cp = CCinit(&C,EVAL_FSM);
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("FSMaddress [pubkey]\n"); throw runtime_error("FSMaddress [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(cp->evalcode) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 ) if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
@@ -5997,7 +5997,7 @@ UniValue auctionaddress(const UniValue& params, bool fHelp)
cp = CCinit(&C,EVAL_AUCTION); cp = CCinit(&C,EVAL_AUCTION);
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("auctionaddress [pubkey]\n"); throw runtime_error("auctionaddress [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(cp->evalcode) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 ) if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
@@ -6010,7 +6010,7 @@ UniValue diceaddress(const UniValue& params, bool fHelp)
cp = CCinit(&C,EVAL_DICE); cp = CCinit(&C,EVAL_DICE);
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("diceaddress [pubkey]\n"); throw runtime_error("diceaddress [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(cp->evalcode) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 ) if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
@@ -6024,7 +6024,7 @@ UniValue faucetaddress(const UniValue& params, bool fHelp)
cp = CCinit(&C,EVAL_FAUCET); cp = CCinit(&C,EVAL_FAUCET);
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("faucetaddress [pubkey]\n"); throw runtime_error("faucetaddress [pubkey]\n");
error = ensure_CCrequirements(0); error = ensure_CCrequirements(cp->evalcode);
if ( error < 0 ) if ( error < 0 )
throw runtime_error(strprintf("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet. ERR=%d\n", error)); throw runtime_error(strprintf("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet. ERR=%d\n", error));
if ( params.size() == 1 ) if ( params.size() == 1 )
@@ -6038,7 +6038,7 @@ UniValue rewardsaddress(const UniValue& params, bool fHelp)
cp = CCinit(&C,EVAL_REWARDS); cp = CCinit(&C,EVAL_REWARDS);
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("rewardsaddress [pubkey]\n"); throw runtime_error("rewardsaddress [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(cp->evalcode) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 ) if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
@@ -6051,7 +6051,7 @@ UniValue assetsaddress(const UniValue& params, bool fHelp)
cp = CCinit(&C, EVAL_ASSETS); cp = CCinit(&C, EVAL_ASSETS);
if (fHelp || params.size() > 1) if (fHelp || params.size() > 1)
throw runtime_error("assetsaddress [pubkey]\n"); throw runtime_error("assetsaddress [pubkey]\n");
if (ensure_CCrequirements(0) < 0) if (ensure_CCrequirements(cp->evalcode) < 0)
throw runtime_error(CC_REQUIREMENTS_MSG); throw runtime_error(CC_REQUIREMENTS_MSG);
if (params.size() == 1) if (params.size() == 1)
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
@@ -6064,7 +6064,7 @@ UniValue tokenaddress(const UniValue& params, bool fHelp)
cp = CCinit(&C,EVAL_TOKENS); cp = CCinit(&C,EVAL_TOKENS);
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("tokenaddress [pubkey]\n"); throw runtime_error("tokenaddress [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(cp->evalcode) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 ) if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
@@ -6077,7 +6077,7 @@ UniValue importgatewayaddress(const UniValue& params, bool fHelp)
cp = CCinit(&C,EVAL_IMPORTGATEWAY); cp = CCinit(&C,EVAL_IMPORTGATEWAY);
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("importgatewayddress [pubkey]\n"); throw runtime_error("importgatewayddress [pubkey]\n");
if ( ensure_CCrequirements(0) < 0 ) if ( ensure_CCrequirements(cp->evalcode) < 0 )
throw runtime_error(CC_REQUIREMENTS_MSG); throw runtime_error(CC_REQUIREMENTS_MSG);
if ( params.size() == 1 ) if ( params.size() == 1 )
pubkey = ParseHex(params[0].get_str().c_str()); pubkey = ParseHex(params[0].get_str().c_str());
@@ -7131,7 +7131,7 @@ UniValue faucetfund(const UniValue& params, bool fHelp)
if ( fHelp || params.size() > 1 ) if ( fHelp || params.size() > 1 )
throw runtime_error("faucetfund amount\n"); throw runtime_error("faucetfund amount\n");
funds = atof(params[0].get_str().c_str()) * COIN + 0.00000000499999; funds = atof(params[0].get_str().c_str()) * COIN + 0.00000000499999;
if ( (0) && KOMODO_NSPV > 0 ) if ( (0) && KOMODO_NSPV_SUPERLITE )
{ {
char coinaddr[64]; struct CCcontract_info *cp,C; CTxOut v; char coinaddr[64]; struct CCcontract_info *cp,C; CTxOut v;
cp = CCinit(&C,EVAL_FAUCET); cp = CCinit(&C,EVAL_FAUCET);

View File

@@ -1841,7 +1841,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
void CWallet::SyncTransaction(const CTransaction& tx, const CBlock* pblock) void CWallet::SyncTransaction(const CTransaction& tx, const CBlock* pblock)
{ {
LOCK2(cs_main, cs_wallet); LOCK(cs_wallet);
if (!AddToWalletIfInvolvingMe(tx, pblock, true)) if (!AddToWalletIfInvolvingMe(tx, pblock, true))
return; // Not one of ours return; // Not one of ours
@@ -4892,9 +4892,8 @@ CWalletKey::CWalletKey(int64_t nExpires)
nTimeExpires = nExpires; nTimeExpires = nExpires;
} }
int CMerkleTx::SetMerkleBranch(const CBlock& block) void CMerkleTx::SetMerkleBranch(const CBlock& block)
{ {
AssertLockHeld(cs_main);
CBlock blockTmp; CBlock blockTmp;
// Update the tx's hashBlock // Update the tx's hashBlock
@@ -4909,21 +4908,10 @@ int CMerkleTx::SetMerkleBranch(const CBlock& block)
vMerkleBranch.clear(); vMerkleBranch.clear();
nIndex = -1; nIndex = -1;
LogPrintf("ERROR: SetMerkleBranch(): couldn't find tx in block\n"); LogPrintf("ERROR: SetMerkleBranch(): couldn't find tx in block\n");
return 0;
} }
// Fill in merkle branch // Fill in merkle branch
vMerkleBranch = block.GetMerkleBranch(nIndex); vMerkleBranch = block.GetMerkleBranch(nIndex);
// Is the tx in a block that's in the main chain
BlockMap::iterator mi = mapBlockIndex.find(hashBlock);
if (mi == mapBlockIndex.end())
return 0;
const CBlockIndex* pindex = (*mi).second;
if (!pindex || !chainActive.Contains(pindex))
return 0;
return chainActive.Height() - pindex->GetHeight() + 1;
} }
int CMerkleTx::GetDepthInMainChainINTERNAL(const CBlockIndex* &pindexRet) const int CMerkleTx::GetDepthInMainChainINTERNAL(const CBlockIndex* &pindexRet) const

View File

@@ -386,7 +386,7 @@ public:
READWRITE(nIndex); READWRITE(nIndex);
} }
int SetMerkleBranch(const CBlock& block); void SetMerkleBranch(const CBlock& block);
/** /**