Merge branch 'FSM' of https://github.com/jl777/komodo into FSM

merge
This commit is contained in:
blackjok3r
2018-12-14 16:42:48 +08:00
18 changed files with 435 additions and 52 deletions

View File

@@ -14,8 +14,10 @@ testScripts=(
'ac_private.py'
'verushash.py'
'cryptoconditions.py'
'cryptoconditions_channels.py'
'cryptoconditions_dice.py'
'cryptoconditions_faucet.py'
'cryptoconditions_gateways.py'
'cryptoconditions_oracles.py'
'cryptoconditions_rewards.py'
'cryptoconditions_token.py'

View File

@@ -0,0 +1,174 @@
#!/usr/bin/env python2
# Copyright (c) 2018 SuperNET developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
from test_framework.test_framework import BitcoinTestFramework
from test_framework.authproxy import JSONRPCException
from test_framework.util import assert_equal, assert_greater_than, \
initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \
stop_nodes, sync_blocks, sync_mempools, wait_bitcoinds, rpc_port, assert_raises
from cryptoconditions import assert_success, assert_error, generate_random_string
class CryptoconditionsChannelsTest(BitcoinTestFramework):
def setup_chain(self):
print("Initializing CC test directory "+self.options.tmpdir)
self.num_nodes = 2
initialize_chain_clean(self.options.tmpdir, self.num_nodes)
def setup_network(self, split = False):
print("Setting up network...")
self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D"
self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf"
self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9"
self.addr1 = "RXEXoa1nRmKhMbuZovpcYwQMsicwzccZBp"
self.pubkey1 = "024026d4ad4ecfc1f705a9b42ca64af6d2ad947509c085534a30b8861d756c6ff0"
self.privkey1 = "UtdydP56pGTFmawHzHr1wDrc4oUwCNW1ttX8Pc3KrvH3MA8P49Wi"
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir,
extra_args=[[
# always give -ac_name as first extra_arg and port as third
'-ac_name=REGTEST',
'-conf='+self.options.tmpdir+'/node0/REGTEST.conf',
'-port=64367',
'-rpcport=64368',
'-regtest',
'-addressindex=1',
'-spentindex=1',
'-ac_supply=5555555',
'-ac_reward=10000000000000',
'-pubkey=' + self.pubkey,
'-ac_cc=2',
'-whitelist=127.0.0.1',
'-debug',
'--daemon',
'-rpcuser=rt',
'-rpcpassword=rt'
],
['-ac_name=REGTEST',
'-conf='+self.options.tmpdir+'/node1/REGTEST.conf',
'-port=64365',
'-rpcport=64366',
'-regtest',
'-addressindex=1',
'-spentindex=1',
'-ac_supply=5555555',
'-ac_reward=10000000000000',
'-pubkey=' + self.pubkey1,
'-ac_cc=2',
'-whitelist=127.0.0.1',
'-debug',
'-addnode=127.0.0.1:64367',
'--daemon',
'-rpcuser=rt',
'-rpcpassword=rt']]
)
self.is_network_split = split
self.rpc = self.nodes[0]
self.rpc1 = self.nodes[1]
self.sync_all()
print("Done setting up network")
def send_and_mine(self, xtn, rpc_connection):
txid = rpc_connection.sendrawtransaction(xtn)
assert txid, 'got txid'
# we need the tx above to be confirmed in the next block
rpc_connection.generate(1)
return txid
def run_channels_tests(self):
"""!!! for testing needed test daemon which built with custom flag
export CONFIGURE_FLAGS='CPPFLAGS=-DTESTMODE'
since in usual mode 101 confirmations are needed for payment/refund
"""
rpc = self.nodes[0]
rpc1 = self.nodes[1]
# getting empty channels list
result = rpc.channelsinfo()
assert_equal(len(result), 2)
assert_equal(result["result"], "success")
assert_equal(result["name"], "Channels Info")
# 10 payments, 100000 sat denomination channel opening with second node pubkey
new_channel_hex = rpc.channelsopen(self.pubkey1, "10", "100000")
assert_success(new_channel_hex)
channel_txid = self.send_and_mine(new_channel_hex["hex"], rpc)
assert channel_txid, "got channel txid"
# checking if our new channel in common channels list
result = rpc.channelsinfo()
assert_equal(len(result), 3)
# checking info about channel directly
result = rpc.channelsinfo(channel_txid)
assert_success(result)
assert_equal(result["Open"], "10 payments of 100000 satoshi")
# open transaction should be confirmed
rpc.generate(1)
# trying to make wrong denomination channel payment
result = rpc.channelspayment(channel_txid, "199000")
assert_error(result)
# trying to make 0 channel payment
result = rpc.channelspayment(channel_txid, "0")
assert_error(result)
# trying to make negative channel payment
result = rpc.channelspayment(channel_txid, "-1")
assert_error(result)
# valid channel payment
result = rpc.channelspayment(channel_txid, "100000")
assert_success(result)
payment_tx_id = self.send_and_mine(result["hex"], rpc)
assert payment_tx_id, "got txid"
# now in channelinfo payment information should appear
result = rpc.channelsinfo(channel_txid)
assert_equal(result["Payment"], "100000 satoshi to {}, 9 payments left".format(self.addr1))
# executing channel close
result = rpc.channelsclose(channel_txid)
assert_success(result)
channel_close_txid = self.send_and_mine(result["hex"], rpc)
assert channel_close_txid, "got txid"
rpc.generate(2)
self.sync_all()
# now in channelinfo closed flag should appear
result = rpc.channelsinfo(channel_txid)
assert_equal(result["Close"], "channel")
# executing channel refund
result = rpc.channelsrefund(channel_txid, channel_close_txid)
assert_success(result)
refund_txid = self.send_and_mine(result["hex"], rpc)
assert refund_txid, "got txid"
def run_test(self):
print("Mining blocks...")
rpc = self.nodes[0]
rpc1 = self.nodes[1]
# utxos from block 1 become mature in block 101
rpc.generate(101)
self.sync_all()
rpc.getinfo()
rpc1.getinfo()
# this corresponds to -pubkey above
print("Importing privkeys")
rpc.importprivkey(self.privkey)
rpc1.importprivkey(self.privkey1)
self.run_channels_tests()
if __name__ == '__main__':
CryptoconditionsChannelsTest().main()

View File

@@ -0,0 +1,157 @@
#!/usr/bin/env python2
# Copyright (c) 2018 SuperNET developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
from test_framework.test_framework import BitcoinTestFramework
from test_framework.authproxy import JSONRPCException
from test_framework.util import assert_equal, assert_greater_than, \
initialize_chain_clean, initialize_chain, start_nodes, start_node, connect_nodes_bi, \
stop_nodes, sync_blocks, sync_mempools, wait_bitcoinds, rpc_port, assert_raises
from cryptoconditions import assert_success, assert_error, generate_random_string
class CryptoconditionsGatewaysTest(BitcoinTestFramework):
def setup_chain(self):
print("Initializing CC test directory "+self.options.tmpdir)
self.num_nodes = 2
initialize_chain_clean(self.options.tmpdir, self.num_nodes)
def setup_network(self, split = False):
print("Setting up network...")
self.addr = "RWPg8B91kfK5UtUN7z6s6TeV9cHSGtVY8D"
self.pubkey = "02676d00110c2cd14ae24f95969e8598f7ccfaa675498b82654a5b5bd57fc1d8cf"
self.privkey = "UqMgxk7ySPNQ4r9nKAFPjkXy6r5t898yhuNCjSZJLg3RAM4WW1m9"
self.addr1 = "RXEXoa1nRmKhMbuZovpcYwQMsicwzccZBp"
self.pubkey1 = "024026d4ad4ecfc1f705a9b42ca64af6d2ad947509c085534a30b8861d756c6ff0"
self.privkey1 = "UtdydP56pGTFmawHzHr1wDrc4oUwCNW1ttX8Pc3KrvH3MA8P49Wi"
self.nodes = start_nodes(self.num_nodes, self.options.tmpdir,
extra_args=[[
# always give -ac_name as first extra_arg and port as third
'-ac_name=REGTEST',
'-conf='+self.options.tmpdir+'/node0/REGTEST.conf',
'-port=64367',
'-rpcport=64368',
'-regtest',
'-addressindex=1',
'-spentindex=1',
'-ac_supply=5555555',
'-ac_reward=10000000000000',
'-pubkey=' + self.pubkey,
'-ac_cc=2',
'-whitelist=127.0.0.1',
'-debug',
'--daemon',
'-rpcuser=rt',
'-rpcpassword=rt'
],
['-ac_name=REGTEST',
'-conf='+self.options.tmpdir+'/node1/REGTEST.conf',
'-port=64365',
'-rpcport=64366',
'-regtest',
'-addressindex=1',
'-spentindex=1',
'-ac_supply=5555555',
'-ac_reward=10000000000000',
'-pubkey=' + self.pubkey1,
'-ac_cc=2',
'-whitelist=127.0.0.1',
'-debug',
'-addnode=127.0.0.1:64367',
'--daemon',
'-rpcuser=rt',
'-rpcpassword=rt']]
)
self.is_network_split = split
self.rpc = self.nodes[0]
self.rpc1 = self.nodes[1]
self.sync_all()
print("Done setting up network")
def send_and_mine(self, xtn, rpc_connection):
txid = rpc_connection.sendrawtransaction(xtn)
assert txid, 'got txid'
# we need the tx above to be confirmed in the next block
rpc_connection.generate(1)
return txid
def run_gateways_tests(self):
rpc = self.nodes[0]
rpc1 = self.nodes[1]
result = rpc.gatewaysaddress()
assert_success(result)
for x in ['GatewaysCCaddress', 'myCCaddress', 'Gatewaysmarker', 'myaddress']:
assert_equal(result[x][0], 'R')
assert_equal("03ea9c062b9652d8eff34879b504eda0717895d27597aaeb60347d65eed96ccb40", result["GatewaysPubkey"])
# getting an empty gateways list
result = rpc.gatewayslist()
assert_equal(result, [])
# Gateways binding preparation
# creating oracle
oracle_hex = rpc.oraclescreate("Test", "Testing", "Ihh")
assert_success(oracle_hex)
oracle_txid = self.send_and_mine(oracle_hex["hex"], rpc)
assert oracle_txid, "got txid"
# registering as an oracle publisher
reg_hex = rpc.oraclesregister(oracle_txid, "10000")
assert_success(reg_hex)
reg_txid = self.send_and_mine(reg_hex["hex"], rpc)
assert reg_txid, "got txid"
# subscribing on oracle
sub_hex = rpc.oraclessubscribe(oracle_txid, self.pubkey, "1")
assert_success(sub_hex)
sub_txid = self.send_and_mine(sub_hex["hex"], rpc)
assert sub_txid, "got txid"
# creating token
token_hex = rpc.tokencreate("Test", "1", "Testing")
assert_success(token_hex)
token_txid = self.send_and_mine(token_hex["hex"], rpc)
assert token_txid, "got txid"
# converting tokens
convertion_hex = rpc.tokenconvert("241",token_txid,"03ea9c062b9652d8eff34879b504eda0717895d27597aaeb60347d65eed96ccb40","100000000")
assert_success(convertion_hex)
convertion_txid = self.send_and_mine(convertion_hex["hex"], rpc)
assert convertion_txid, "got txid"
# binding gateway
bind_hex = rpc.gatewaysbind(token_txid, oracle_txid, "KMD", "100000000", "1", "1", self.pubkey)
assert_success(bind_hex)
bind_txid = self.send_and_mine(bind_hex["hex"], rpc)
assert bind_txid, "got txid"
# checking if created gateway in list
result = rpc.gatewayslist()
assert_equal(result[0], bind_txid)
def run_test(self):
print("Mining blocks...")
rpc = self.nodes[0]
rpc1 = self.nodes[1]
# utxos from block 1 become mature in block 101
rpc.generate(101)
self.sync_all()
rpc.getinfo()
rpc1.getinfo()
# this corresponds to -pubkey above
print("Importing privkeys")
rpc.importprivkey(self.privkey)
rpc1.importprivkey(self.privkey1)
self.run_gateways_tests()
if __name__ == '__main__':
CryptoconditionsGatewaysTest().main()

View File

@@ -11,7 +11,7 @@ if [ -z "$delay" ]; then delay=20; fi
./listassetchainparams | while read args; do
gen=""
if [ $[RANDOM % 10] == 1 ]; then
gen=" -gen"
gen=" -gen -genproclimit=1"
fi
./komodod $gen $args $overide_args -pubkey=$pubkey -addnode=$seed_ip &

View File

@@ -94,7 +94,8 @@
},
{
"ac_name": "OOT",
"ac_supply": "216000000"
"ac_supply": "216000000",
"ac_sapling": "5000000"
},
{
"ac_name": "BNTN",
@@ -123,7 +124,11 @@
},
{
"ac_name": "ZILLA",
"ac_supply": "11000000"
"ac_supply": "11000000",
"ac_sapling": "5000000",
"addnode": [
"51.68.215.104"
]
},
{
"ac_name": "RFOX",

View File

@@ -27,14 +27,14 @@ echo $pubkey
./komodod -pubkey=$pubkey -ac_name=BEER -ac_supply=100000000 -addnode=78.47.196.146 &
./komodod -pubkey=$pubkey -ac_name=PIZZA -ac_supply=100000000 -addnode=78.47.196.146 &
./komodod -pubkey=$pubkey -ac_name=NINJA -ac_supply=100000000 -addnode=78.47.196.146 &
./komodod -pubkey=$pubkey -ac_name=OOT -ac_supply=216000000 -addnode=174.138.107.226 &
./komodod -pubkey=$pubkey -ac_name=OOT -ac_supply=216000000 -ac_sapling=5000000 -addnode=174.138.107.226 &
./komodod -pubkey=$pubkey -ac_name=BNTN -ac_supply=500000000 -addnode=94.130.169.205 &
./komodod -pubkey=$pubkey -ac_name=CHAIN -ac_supply=999999 -addnode=78.47.146.222 &
./komodod -pubkey=$pubkey -ac_name=PRLPAY -ac_supply=500000000 -addnode=13.250.226.125 &
./komodod -pubkey=$pubkey -ac_name=DSEC -ac_supply=7000000 -addnode=185.148.147.30 &
./komodod -pubkey=$pubkey -ac_name=GLXT -ac_supply=10000000000 -addnode=13.230.224.15 &
./komodod -pubkey=$pubkey -ac_name=EQL -ac_supply=500000000 -ac_ccactivate=205000 -addnode=46.101.124.153 &
./komodod -pubkey=$pubkey -ac_name=ZILLA -ac_supply=11000000 -addnode=54.39.23.248 &
./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=78.47.196.146 &
~/VerusCoin/src/komodod -pubkey=$pubkey -ac_name=VRSC -ac_algo=verushash -ac_cc=1 -ac_veruspos=50 -ac_supply=0 -ac_eras=3 -ac_reward=0,38400000000,2400000000 -ac_halving=1,43200,1051920 -ac_decay=100000000,0,0 -ac_end=10080,226080,0 -ac_timelockgte=19200000000 -ac_timeunlockfrom=129600 -ac_timeunlockto=1180800 -addnode=185.25.48.236 -addnode=185.64.105.111 &
./komodod -pubkey=$pubkey -ac_name=SEC -ac_cc=333 -ac_supply=1000000000 -addnode=185.148.145.43 &

View File

@@ -62,8 +62,26 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
GetCCaddress(cp,myaddr,mypk);
mycond = MakeCCcond1(cp->evalcode,mypk);
GetCCaddress(cp,unspendable,unspendablepk);
othercond = MakeCCcond1(cp->evalcode,unspendablepk);
//fprintf(stderr,"myCCaddr.(%s) %p vs unspendable.(%s) %p\n",myaddr,mycond,unspendable,othercond);
othercond = MakeCCcond1(cp->evalcode,unspendablepk);
//Reorder vins so that for multiple normal vins all other except vin0 goes to the end
//This is a must to avoid hardfork change of validation in every CC, because there could be maximum one normal vin at the begining with current validation.
for (i=0; i<n; i++)
{
if ( GetTransaction(mtx.vin[i].prevout.hash,vintx,hashBlock,false) != 0 )
{
if ( vintx.vout[mtx.vin[i].prevout.n].scriptPubKey.IsPayToCryptoCondition() == 0 && ccvins==0)
normalvins++;
else ccvins++;
}
}
if (normalvins>1 && ccvins)
{
for(i=1;i<normalvins;i++)
{
mtx.vin.push_back(mtx.vin[1]);
mtx.vin.erase(mtx.vin.begin() + 1);
}
}
memset(utxovalues,0,sizeof(utxovalues));
for (i=0; i<n; i++)
{
@@ -74,14 +92,12 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
totalinputs += utxovalues[i];
if ( vintx.vout[utxovout].scriptPubKey.IsPayToCryptoCondition() == 0 )
{
//fprintf(stderr,"vin.%d is normal %.8f\n",i,(double)utxovalues[i]/COIN);
if (ccvins==0) normalvins++;
//fprintf(stderr,"vin.%d is normal %.8f\n",i,(double)utxovalues[i]/COIN);
normalinputs += utxovalues[i];
vinimask |= (1LL << i);
}
else
{
ccvins++;
{
mask |= (1LL << i);
}
} else fprintf(stderr,"FinalizeCCTx couldnt find %s\n",mtx.vin[i].prevout.hash.ToString().c_str());
@@ -98,16 +114,6 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran
mtx.vout.push_back(CTxOut(0,opret));
PrecomputedTransactionData txdata(mtx);
n = mtx.vin.size();
//Reorder vins so that for multiple normal vins all other except vin0 goes to the end
//This is a must to avoid hardfork change of validation in every CC, because there could be maximum one normal vin at the begining with current validation.
if (normalvins>1)
{
for(i=1;i<normalvins;i++)
{
mtx.vin.push_back(mtx.vin[1]);
mtx.vin.erase(mtx.vin.begin() + 1);
}
}
for (i=0; i<n; i++)
{
if ( GetTransaction(mtx.vin[i].prevout.hash,vintx,hashBlock,false) != 0 )

View File

@@ -906,7 +906,7 @@ int32_t main(int32_t argc,char **argv)
zsaddr = clonestr(argv[2]);
printf("%s: %s %s\n",REFCOIN_CLI,coinstr,zsaddr);
uint32_t lastopid; char coinaddr[64],zcaddr[128],opidstr[128]; int32_t finished; int64_t amount,stdamount,txfee;
stdamount = 10000 * SATOSHIDEN;
stdamount = 1000 * SATOSHIDEN;
txfee = 10000;
again:
printf("start processing zmigrate\n");

View File

@@ -427,11 +427,11 @@ void *dicefinish(void *_ptr)
if ( vin0_needed > 0 )
{
num = 0;
//fprintf(stderr,"iter.%d vin0_needed.%d\n",iter,vin0_needed);
//fprintf(stderr,"iter.%d vin0_needed.%d\n",iter,vin0_needed);
utxos = (struct dicefinish_utxo *)calloc(vin0_needed,sizeof(*utxos));
if ( (n= dicefinish_utxosget(num,utxos,vin0_needed,coinaddr)) > 0 )
{
//fprintf(stderr,"iter.%d vin0_needed.%d got %d, num 0.0002 %d\n",iter,vin0_needed,n,num);
//fprintf(stderr,"iter.%d vin0_needed.%d got %d, num 0.0002 %d\n",iter,vin0_needed,n,num);
m = 0;
DL_FOREACH_SAFE(DICEFINISH_LIST,ptr,tmp)
{
@@ -484,7 +484,8 @@ void *dicefinish(void *_ptr)
//fprintf(stderr,"error ready.%d dicefinish %d of %d process %s %s using need %.8f finish.%s size.%d betspent.%d\n",ptr->bettxid_ready,m,n,iter<0?"loss":"win",ptr->bettxid.GetHex().c_str(),(double)(iter<0 ? 0 : ptr->winamount)/COIN,ptr->txid.GetHex().c_str(),(int32_t)ptr->rawtx.size(),dice_betspent((char *)"dicefinish",ptr->bettxid));
}
}
}
} else if ( system("cc/dapps/sendmany100") != 0 )
fprintf(stderr,"error issing cc/dapps/sendmany100\n");
free(utxos);
}
}
@@ -533,7 +534,7 @@ void DiceQueue(int32_t iswin,uint64_t sbits,uint256 fundingtxid,uint256 bettxid,
else
{
//fprintf(stderr,"DiceQueue status bettxid.%s already in list\n",bettxid.GetHex().c_str());
_dicehash_clear(bettxid);
//_dicehash_clear(bettxid);
}
pthread_mutex_unlock(&DICE_MUTEX);
}

View File

@@ -1,9 +1,9 @@
#! /bin/sh
# Wrapper for compilers which do not understand '-c -o'.
scriptversion=2012-10-14.11; # UTC
scriptversion=2018-03-07.03; # UTC
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
# Copyright (C) 1999-2018 Free Software Foundation, Inc.
# Written by Tom Tromey <tromey@cygnus.com>.
#
# This program is free software; you can redistribute it and/or modify
@@ -17,7 +17,7 @@ scriptversion=2012-10-14.11; # UTC
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
@@ -255,7 +255,8 @@ EOF
echo "compile $scriptversion"
exit $?
;;
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe )
cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \
icl | *[/\\]icl | icl.exe | *[/\\]icl.exe )
func_cl_wrapper "$@" # Doesn't return...
;;
esac
@@ -339,9 +340,9 @@ exit $ret
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# eval: (add-hook 'before-save-hook 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-time-zone: "UTC"
# time-stamp-time-zone: "UTC0"
# time-stamp-end: "; # UTC"
# End:

View File

@@ -155,6 +155,8 @@ int64_t komodo_current_supply(uint32_t nHeight)
uint64_t lastEnd = j == 0 ? 0 : ASSETCHAINS_ENDSUBSIDY[j - 1];
uint64_t curEnd = ASSETCHAINS_ENDSUBSIDY[j] == 0 ? nHeight : nHeight > ASSETCHAINS_ENDSUBSIDY[j] ? ASSETCHAINS_ENDSUBSIDY[j] : nHeight;
uint64_t period = ASSETCHAINS_HALVING[j];
if ( period == 0 )
period = 210000;
uint32_t nSteps = (curEnd - lastEnd) / period;
uint32_t modulo = (curEnd - lastEnd) % period;
uint64_t decay = ASSETCHAINS_DECAY[j];
@@ -208,7 +210,8 @@ int64_t komodo_current_supply(uint32_t nHeight)
// calculate amount in one step's triangular protrusion over minor triangle's hypotenuse
denominator = nSteps * period;
if ( denominator == 0 )
denominator = 1;
// difference of one step vs. total
stepDifference = (period * subsidyDifference) / denominator;

View File

@@ -4695,6 +4695,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C
mempool.remove(tx, removed, false);
}
// add all the txs in the block to the empty mempool.
// CC validation shouldnt (cant) depend on the state of mempool!
while ( 1 )
{
for (i=0; i<block.vtx.size(); i++)
@@ -4764,18 +4765,28 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C
{
// here we add back all txs from the temp mempool to the main mempool.
// which removes any tx locally that were invalid after the block arrives.
int invalidtxs = 0;
int numadded,numiters = 0;
CValidationState state; bool fMissingInputs,fOverrideFees = false;
list<CTransaction> removed;
LOCK(mempool.cs);
BOOST_FOREACH(const CTxMemPoolEntry& e, tmpmempool.mapTx) {
CTransaction tx = e.GetTx();
CValidationState state; bool fMissingInputs,fOverrideFees = false;
if (AcceptToMemoryPool(mempool, state, tx, false, &fMissingInputs, !fOverrideFees) == false )
invalidtxs++;
//else fprintf(stderr, "added mempool tx back to mempool\n");
while ( 1 )
{
numiters++;
numadded = 0;
BOOST_FOREACH(const CTxMemPoolEntry& e, tmpmempool.mapTx)
{
CTransaction tx = e.GetTx();
if (AcceptToMemoryPool(mempool, state, tx, false, &fMissingInputs, !fOverrideFees) == true )
{
numadded++;
tmpmempool.remove(tx, removed, false);
}
}
if ( numadded == 0 )
break;
}
if ( 0 && invalidtxs > 0 )
fprintf(stderr, "number of invalid txs: %d\n",invalidtxs );
if ( 0 && numadded > 0 )
fprintf(stderr, "CC mempool add: numiters.%d numadded.%d remains.%d\n",numiters,numadded,(int32_t)tmpmempool.size());
// empty the temp mempool for next time.
tmpmempool.clear();
}

View File

@@ -1492,13 +1492,18 @@ void ThreadOpenAddedConnections()
LOCK(cs_vNodes);
BOOST_FOREACH(CNode* pnode, vNodes)
for (list<vector<CService> >::iterator it = lservAddressesToAdd.begin(); it != lservAddressesToAdd.end(); it++)
{
BOOST_FOREACH(const CService& addrNode, *(it))
if (pnode->addr == addrNode)
{
it = lservAddressesToAdd.erase(it);
it--;
if ( it != lservAddressesToAdd.begin() )
it--;
break;
}
if (it == lservAddressesToAdd.end())
break;
}
}
BOOST_FOREACH(vector<CService>& vserv, lservAddressesToAdd)
{

View File

@@ -56,7 +56,7 @@ extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
uint32_t komodo_segid32(char *coinaddr);
int64_t komodo_coinsupply(int64_t *zfundsp,int32_t height);
int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp);
#define KOMODO_VERSION "0.3.2"
#define KOMODO_VERSION "0.3.1"
#define VERUS_VERSION "0.4.0g"
extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
extern uint32_t ASSETCHAINS_CC;

View File

@@ -1167,12 +1167,12 @@ UniValue signrawtransaction(const UniValue& params, bool fHelp)
if ( txConst.IsCoinBase() != 0 )
{
if ( (txpow & 2) == 0 )
txpow == 0;
txpow = 0;
}
else
{
if ( (txpow & 1) == 0 )
txpow == 0;
txpow = 0;
}
}
while ( 1 )

View File

@@ -33,7 +33,10 @@ extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue&
void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex);
int32_t komodo_longestchain();
int32_t komodo_dpowconfs(int32_t height,int32_t numconfs);
<<<<<<< HEAD:src/rpcblockchain.old
extern int32_t KOMODO_LONGESTCHAIN;
=======
>>>>>>> master:src/rpcblockchain.cpp
double GetDifficultyINTERNAL(const CBlockIndex* blockindex, bool networkDifficulty)
{

View File

@@ -111,7 +111,6 @@ void WalletTxToJSON(const CWalletTx& wtx, UniValue& entry)
entry.push_back(Pair("blocktime", mapBlockIndex[wtx.hashBlock]->GetBlockTime()));
entry.push_back(Pair("expiryheight", (int64_t)wtx.nExpiryHeight));
} else entry.push_back(Pair("confirmations", confirms));
uint256 hash = wtx.GetHash();
entry.push_back(Pair("txid", hash.GetHex()));
UniValue conflicts(UniValue::VARR);
@@ -1666,6 +1665,7 @@ void ListTransactions(const CWalletTx& wtx, const string& strAccount, int nMinDe
BOOST_FOREACH(const COutputEntry& r, listReceived)
{
string account;
//fprintf(stderr,"recv iter %s\n",wtx.GetHash().GetHex().c_str());
if (pwalletMain->mapAddressBook.count(r.destination))
account = pwalletMain->mapAddressBook[r.destination].name;
if (fAllAccounts || (account == strAccount))
@@ -1816,7 +1816,10 @@ UniValue listtransactions(const UniValue& params, bool fHelp)
{
CWalletTx *const pwtx = (*it).second.first;
if (pwtx != 0)
{
//fprintf(stderr,"pwtx iter.%d %s\n",(int32_t)pwtx->nOrderPos,pwtx->GetHash().GetHex().c_str());
ListTransactions(*pwtx, strAccount, 0, true, ret, filter);
} //else fprintf(stderr,"null pwtx\n");
CAccountingEntry *const pacentry = (*it).second.second;
if (pacentry != 0)
AcentryToJSON(*pacentry, strAccount, ret);

View File

@@ -1304,6 +1304,7 @@ CWallet::TxItems CWallet::OrderedTxItems(std::list<CAccountingEntry>& acentries,
{
CWalletTx* wtx = &((*it).second);
txOrdered.insert(make_pair(wtx->nOrderPos, TxPair(wtx, (CAccountingEntry*)0)));
//fprintf(stderr,"ordered iter.%d %s\n",(int32_t)wtx->nOrderPos,wtx->GetHash().GetHex().c_str());
}
acentries.clear();
walletdb.ListAccountCreditDebit(strAccount, acentries);
@@ -2521,6 +2522,7 @@ void CWalletTx::GetAmounts(list<COutputEntry>& listReceived,
}
// Sent/received.
int32_t oneshot = 0;
for (unsigned int i = 0; i < vout.size(); ++i)
{
const CTxOut& txout = vout[i];
@@ -2532,11 +2534,19 @@ void CWalletTx::GetAmounts(list<COutputEntry>& listReceived,
{
// Don't report 'change' txouts
if (!(filter & ISMINE_CHANGE) && pwallet->IsChange(txout))
continue;
{
if ( oneshot++ > 1 )
{
//fprintf(stderr,"skip change vout\n");
continue;
}
}
}
else if (!(fIsMine & filter))
{
//fprintf(stderr,"skip filtered vout %d %d\n",(int32_t)fIsMine,(int32_t)filter);
continue;
}
// In either case, we need to get the destination address
CTxDestination address;
if (!ExtractDestination(txout.scriptPubKey, address))
@@ -2550,10 +2560,12 @@ void CWalletTx::GetAmounts(list<COutputEntry>& listReceived,
// If we are debited by the transaction, add the output as a "sent" entry
if (nDebit > 0)
listSent.push_back(output);
//else fprintf(stderr,"not sent vout %d %d\n",(int32_t)fIsMine,(int32_t)filter);
// If we are receiving the output, add it as a "received" entry
if (fIsMine & filter)
listReceived.push_back(output);
//else fprintf(stderr,"not received vout %d %d\n",(int32_t)fIsMine,(int32_t)filter);
}
}
@@ -3615,7 +3627,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
if (!NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) {
max_tx_size = MAX_TX_SIZE_BEFORE_SAPLING;
}
/*
// Discourage fee sniping.
//
// However because of a off-by-one-error in previous versions we need to
@@ -3636,7 +3648,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
txNew.nLockTime = std::max(0, (int)txNew.nLockTime - GetRandInt(100));
assert(txNew.nLockTime <= (unsigned int)chainActive.Height());
assert(txNew.nLockTime < LOCKTIME_THRESHOLD);
assert(txNew.nLockTime < LOCKTIME_THRESHOLD);*/
{
LOCK2(cs_main, cs_wallet);