From fde85d291fe528fcd6303524c43c89f0195eb8f4 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Thu, 30 Aug 2018 10:56:06 +0200 Subject: [PATCH 001/135] Add some helpful error messages for when Diceinit fails --- src/cc/dice.cpp | 14 +++++++++----- src/wallet/rpcwallet.cpp | 5 ++++- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 50b9cba78..4d2675d8b 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -882,7 +882,7 @@ std::string DiceCreateFunding(uint64_t txfee,char *planstr,int64_t funds,int64_t memset(&zero,0,sizeof(zero)); if ( (cp= Diceinit(fundingPubKey,zero,&C,planstr,txfee,mypk,dicepk,sbits,a,b,c,d)) == 0 ) { - CCerror = "Diceinit error in create funding"; + CCerror = "Diceinit error in create funding, is your transaction confirmed?"; fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } @@ -907,8 +907,10 @@ std::string DiceAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,int6 fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } - if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,sbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) + if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,sbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { + CCerror = "Diceinit error in add funding, is your transaction confirmed?"; return(""); + } scriptPubKey = CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG; if ( 0 ) { @@ -956,8 +958,10 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } - if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,sbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) + if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,sbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { + CCerror = "Diceinit error in bet, is your transaction confirmed?"; return(""); + } if ( bet < minbet || bet > maxbet || odds > maxodds ) { CCerror = strprintf("Dice plan %s illegal bet %.8f: minbet %.8f maxbet %.8f or odds %d vs max.%d\n",planstr,(double)bet/COIN,(double)minbet/COIN,(double)maxbet/COIN,(int32_t)odds,(int32_t)maxodds); @@ -997,7 +1001,7 @@ std::string DiceBetFinish(int32_t *resultp,uint64_t txfee,char *planstr,uint256 //char str[65]; fprintf(stderr,"DiceBetFinish.%s %s\n",planstr,uint256_str(str,bettxid)); if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,sbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { - CCerror = "Diceinit error in finish"; + CCerror = "Diceinit error in finish, is your transaction confirmed?"; fprintf(stderr,"%s\n", CCerror.c_str() ); return(""); } @@ -1110,7 +1114,7 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx CScript fundingPubKey,scriptPubKey; CTransaction spenttx,betTx; uint256 hash,proof,txid,hashBlock,spenttxid; CPubKey mypk,dicepk,fundingpk; struct CCcontract_info *cp,C; int32_t i,result,vout,n=0; int64_t minbet,maxbet,maxodds,timeoutblocks; uint64_t sbits; char coinaddr[64]; std::string res; if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,sbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { - CCerror = "Diceinit error in status"; + CCerror = "Diceinit error in status, is your transaction confirmed?"; fprintf(stderr,"%s\n", CCerror.c_str() ); return(0.); } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b99fffa59..467298be1 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5303,7 +5303,10 @@ UniValue dicebet(const UniValue& params, bool fHelp) } if (amount > 0 && odds > 0) { hex = DiceBet(0,name,fundingtxid,amount,odds); - if ( hex.size() > 0 ) + if ( CCerror != "" ) + { + ERR_RESULT(CCerror); + } else if ( hex.size() > 0 ) { result.push_back(Pair("result", "success")); result.push_back(Pair("hex", hex)); From 6b52965769535c6baf8d28633c4e26362b23c848 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 17 Sep 2018 01:03:14 -1100 Subject: [PATCH 002/135] Stronger check for asset chain notarizations --- src/main.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index ce61a0e35..21c803754 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3370,6 +3370,15 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { CBlock block; if (!ReadBlockFromDisk(block, pindexDelete,1)) return AbortNode(state, "Failed to read block"); + { + int32_t prevMoMheight; uint256 notarizedhash,txid; + komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); + if ( block.GetHash() == notarizedhash ) + { + fprintf(stderr,"DisconnectTip trying to disconnect notarized block at ht.%d\n",(int32_t)pindexDelete->nHeight); + return(false); + } + } // Apply the block atomically to the chain state. uint256 anchorBeforeDisconnect = pcoinsTip->GetBestAnchor(); int64_t nStart = GetTimeMicros(); From 12832b1d22add227ccd6bd8a72732d519dc6e64d Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 17 Sep 2018 01:04:30 -1100 Subject: [PATCH 003/135] notarization check for asset chains --- resolve.sh | 12 ++++++++++++ src/main.cpp | 10 ++++++++++ 2 files changed, 22 insertions(+) create mode 100755 resolve.sh diff --git a/resolve.sh b/resolve.sh new file mode 100755 index 000000000..548e71dee --- /dev/null +++ b/resolve.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +for f in $(git diff --name-only --diff-filter=U | cat); do + echo "Resolve conflict in $f ..." + git checkout --theirs $f +done + +for f in $(git diff --name-only --diff-filter=U | cat); do + echo "Adding file $f ..." + git add $f +done + diff --git a/src/main.cpp b/src/main.cpp index e25d6419b..f93cab2f5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3367,6 +3367,16 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) { CBlock block; if (!ReadBlockFromDisk(block, pindexDelete,1)) return AbortNode(state, "Failed to read block"); + if ( ASSETCHAINS_SYMBOL[0] != 0 || pindexDelete->nHeight > 1400000 ) + { + int32_t prevMoMheight; uint256 notarizedhash,txid; + komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); + if ( block.GetHash() == notarizedhash ) + { + fprintf(stderr,"DisconnectTip trying to disconnect notarized block at ht.%d\n",(int32_t)pindexDelete->nHeight); + return(false); + } + } // Apply the block atomically to the chain state. uint256 anchorBeforeDisconnect = pcoinsTip->GetBestAnchor(); int64_t nStart = GetTimeMicros(); From a510b0f883aaf561ef58c728c463306b3b4dbe40 Mon Sep 17 00:00:00 2001 From: "Jonathan \"Duke\" Leto" Date: Sun, 23 Sep 2018 10:49:46 -0700 Subject: [PATCH 004/135] Add Hush to dpowassets --- src/dpowassets | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dpowassets b/src/dpowassets index 88e6f72b8..f691533ba 100755 --- a/src/dpowassets +++ b/src/dpowassets @@ -40,3 +40,4 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dp curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"VRSC\",\"freq\":10,\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"SEC\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CCL\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"HUSH\",\"pubkey\":\"$pubkey\"}" From f425c7eea5e289f9e0e94845de461eb0033eabde Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 23 Sep 2018 07:49:02 -1100 Subject: [PATCH 005/135] Support for notarizing PRIVATE --- src/komodo_notary.h | 1 + src/main.cpp | 78 ++++++++++++++++++++++++++++++++++----------- 2 files changed, 60 insertions(+), 19 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 4711a9afc..04fd30d5f 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -197,6 +197,7 @@ const char *Notaries_elected1[][2] = {"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" }, {"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" }, }; +#define CRYPTO777_PUBSECPSTR "020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9" int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp) { diff --git a/src/main.cpp b/src/main.cpp index 21c803754..e8d0acd98 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -60,6 +60,8 @@ extern int32_t KOMODO_LOADINGBLOCKS,KOMODO_LONGESTCHAIN,KOMODO_INSYNC,KOMODO_CON int32_t KOMODO_NEWBLOCKS; int32_t komodo_block2pubkey33(uint8_t *pubkey33,CBlock *block); void komodo_broadcast(CBlock *pblock,int32_t limit); +void komodo_broadcast(CBlock *pblock,int32_t limit); +bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey); BlockMap mapBlockIndex; CChain chainActive; @@ -1036,6 +1038,28 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state, } } +int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only +{ + static int32_t didinit; static char notaryaddrs[sizeof(Notaries_elected1)/sizeof(*Notaries_elected1) + 1][64]; + int32_t i; + if ( didinit == 0 ) + { + uint8_t pubkey33[33]; + for (i=0; i<=sizeof(Notaries_elected1)/sizeof(*Notaries_elected1); i++) + { + if ( i < sizeof(Notaries_elected1)/sizeof(*Notaries_elected1) ) + decode_hex(pubkey33,33,(char *)Notaries_elected1[i][1]); + else decode_hex(pubkey33,33,(char *)CRYPTO777_PUBSECPSTR); + pubkey2addr((char *)notaryaddrs[i],(uint8_t *)pubkey33); + } + didinit = 1; + } + for (i=0; i<=sizeof(Notaries_elected1)/sizeof(*Notaries_elected1); i++) + if ( strcmp(coinaddr,notaryaddrs[i]) == 0 ) + return(1); + return(0); +} + bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidationState &state) { // Basic checks that don't depend on any context @@ -1112,9 +1136,14 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio } if ( ASSETCHAINS_PRIVATE != 0 ) { - fprintf(stderr,"private chain nValue %.8f iscoinbase.%d\n",(double)txout.nValue/COIN,iscoinbase); + //fprintf(stderr,"private chain nValue %.8f iscoinbase.%d\n",(double)txout.nValue/COIN,iscoinbase); if ( (txout.nValue > 0 && iscoinbase == 0) || tx.GetJoinSplitValueOut() > 0 ) - return state.DoS(100, error("CheckTransaction(): this is a private chain, no public allowed"),REJECT_INVALID, "bad-txns-acprivacy-chain"); + { + char destaddr[65]; + Getscriptaddress(destaddr,txout.scriptPubKey); + if ( komodo_isnotaryvout(destaddr) == 0 ) + return state.DoS(100, error("CheckTransaction(): this is a private chain, no public allowed"),REJECT_INVALID, "bad-txns-acprivacy-chain"); + } } if ( txout.scriptPubKey.size() > IGUANA_MAXSCRIPTSIZE ) return state.DoS(100, error("CheckTransaction(): txout.scriptPubKey.size() too big"),REJECT_INVALID, "bad-txns-vout-negative"); @@ -3621,23 +3650,34 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo // our genesis block. In practice this (probably) won't happen because of checks elsewhere. auto reorgLength = pindexOldTip ? pindexOldTip->nHeight - (pindexFork ? pindexFork->nHeight : -1) : 0; static_assert(MAX_REORG_LENGTH > 0, "We must be able to reorg some distance"); - if (reorgLength > MAX_REORG_LENGTH) { - auto msg = strprintf(_( - "A block chain reorganization has been detected that would roll back %d blocks! " - "This is larger than the maximum of %d blocks, and so the node is shutting down for your safety." - ), reorgLength, MAX_REORG_LENGTH) + "\n\n" + - _("Reorganization details") + ":\n" + - "- " + strprintf(_("Current tip: %s, height %d, work %s"), - pindexOldTip->phashBlock->GetHex(), pindexOldTip->nHeight, pindexOldTip->nChainWork.GetHex()) + "\n" + - "- " + strprintf(_("New tip: %s, height %d, work %s"), - pindexMostWork->phashBlock->GetHex(), pindexMostWork->nHeight, pindexMostWork->nChainWork.GetHex()) + "\n" + - "- " + strprintf(_("Fork point: %s %s, height %d"), - ASSETCHAINS_SYMBOL,pindexFork->phashBlock->GetHex(), pindexFork->nHeight) + "\n\n" + - _("Please help, human!"); - LogPrintf("*** %s\n", msg); - uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_ERROR); - StartShutdown(); - return false; + if (reorgLength > MAX_REORG_LENGTH) + { + int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid; + notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid); + if ( pindexFork->nHeight < notarizedht ) + { + fprintf(stderr,"pindexFork->nHeight.%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->nHeight,notarizedht); + pindexFork = pindexOldTip; + } + else + { + auto msg = strprintf(_( + "A block chain reorganization has been detected that would roll back %d blocks! " + "This is larger than the maximum of %d blocks, and so the node is shutting down for your safety." + ), reorgLength, MAX_REORG_LENGTH) + "\n\n" + + _("Reorganization details") + ":\n" + + "- " + strprintf(_("Current tip: %s, height %d, work %s"), + pindexOldTip->phashBlock->GetHex(), pindexOldTip->nHeight, pindexOldTip->nChainWork.GetHex()) + "\n" + + "- " + strprintf(_("New tip: %s, height %d, work %s"), + pindexMostWork->phashBlock->GetHex(), pindexMostWork->nHeight, pindexMostWork->nChainWork.GetHex()) + "\n" + + "- " + strprintf(_("Fork point: %s %s, height %d"), + ASSETCHAINS_SYMBOL,pindexFork->phashBlock->GetHex(), pindexFork->nHeight) + "\n\n" + + _("Please help, human!"); + LogPrintf("*** %s\n", msg); + uiInterface.ThreadSafeMessageBox(msg, "", CClientUIInterface::MSG_ERROR); + StartShutdown(); + return false; + } } // Disconnect active blocks which are no longer in the best chain. From 54731d91b57d33de9108c25b7793dfab4478c013 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 23 Sep 2018 07:51:25 -1100 Subject: [PATCH 006/135] Pubkey2addr --- src/cc/CCutils.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 3c38d04b3..6aceb5bf4 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -142,6 +142,14 @@ bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey) return(false); } +bool pubkey2addr(char *destaddr,uint8_t *pubkey33) +{ + std::vectorpk; int32_t i; + for (i=0; i<33; i++) + pk.push_back(pubkey33[i]); + return(Getscriptaddress(destaddr,CScript() << pk << OP_CHECKSIG)); +} + bool GetCCaddress(struct CCcontract_info *cp,char *destaddr,CPubKey pk) { CC *payoutCond; From 2d450767051c8a23713ece076879b9f4498a1c78 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 23 Sep 2018 07:52:31 -1100 Subject: [PATCH 007/135] bool pubkey2addr(char *destaddr,uint8_t *pubkey33); --- src/komodo_globals.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 918e7c4f6..02c6a2f1d 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -29,6 +29,7 @@ uint64_t komodo_paxtotal(); int32_t komodo_longestchain(); uint64_t komodo_maxallowed(int32_t baseid); int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max); +bool pubkey2addr(char *destaddr,uint8_t *pubkey33); pthread_mutex_t komodo_mutex; From 037c101c85229fa774fe481039cc7bc3ca5e30f0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 23 Sep 2018 08:11:42 -1100 Subject: [PATCH 008/135] +print --- src/komodo_utils.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 79c0b4671..75f68d87d 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1705,7 +1705,10 @@ void komodo_args(char *argv0) BITCOIND_RPCPORT = GetArg("-rpcport", ASSETCHAINS_RPCPORT); //fprintf(stderr,"(%s) port.%u chain params initialized\n",ASSETCHAINS_SYMBOL,BITCOIND_RPCPORT); if ( strcmp("PIRATE",ASSETCHAINS_SYMBOL) == 0 && ASSETCHAINS_HALVING == 77777 ) + { ASSETCHAINS_HALVING *= 5; + fprintf(stderr,"PIRATE halving changed to %d %.1f days\n",(int32_t)ASSETCHAINS_HALVING,(double)ASSETCHAINS_HALVING/1440); + } } else BITCOIND_RPCPORT = GetArg("-rpcport", BaseParams().RPCPort()); } From b9281f45e7077b70706623fb85b43c8169a8fbdc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 23 Sep 2018 08:36:47 -1100 Subject: [PATCH 009/135] 5x PIRATE halving --- src/komodo_utils.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 23e6b280e..64b283fb5 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1699,6 +1699,11 @@ void komodo_args(char *argv0) { BITCOIND_RPCPORT = GetArg("-rpcport", ASSETCHAINS_RPCPORT); //fprintf(stderr,"(%s) port.%u chain params initialized\n",ASSETCHAINS_SYMBOL,BITCOIND_RPCPORT); + if ( strcmp("PIRATE",ASSETCHAINS_SYMBOL) == 0 && ASSETCHAINS_HALVING == 77777 ) + { + ASSETCHAINS_HALVING *= 5; + fprintf(stderr,"PIRATE halving changed to %d %.1f days\n",(int32_t)ASSETCHAINS_HALVING,(double)ASSETCHAINS_HALVING/1440); + } } else BITCOIND_RPCPORT = GetArg("-rpcport", BaseParams().RPCPort()); } From 7097b79097a3241be3373725966a928dcac7f622 Mon Sep 17 00:00:00 2001 From: SHossain Date: Sun, 23 Sep 2018 20:52:43 +0100 Subject: [PATCH 010/135] Update assetchains.json --- src/assetchains.json | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/assetchains.json b/src/assetchains.json index ceda4cce1..0a9a6b93c 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -146,4 +146,14 @@ "195.201.22.89" ] } + { + "ac_name": "PIRATE", + "ac_supply": "0", + "ac_reward": "25600000000", + "ac_halving": "77777", + "ac_private": "1", + "addnode": [ + "136.243.102.225" + ] + } ] From 9630b8ec9630288477e637bce9e5786dd48e63d7 Mon Sep 17 00:00:00 2001 From: SHossain Date: Sun, 23 Sep 2018 20:53:54 +0100 Subject: [PATCH 011/135] Update assetchains.old --- src/assetchains.old | 1 + 1 file changed, 1 insertion(+) diff --git a/src/assetchains.old b/src/assetchains.old index 158e62cad..2e9218d64 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -39,3 +39,4 @@ echo $pubkey ~/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 & ./komodod -pubkey=$pubkey -ac_name=CCL -ac_supply=200000000 -ac_end=1 -ac_cc=2 -addressindex=1 -spentindex=1 -addnode=142.93.136.89 -addnode=195.201.22.89 & +./komodod -pubkey=$pubkey -ac_name=PIRATE -ac_supply=0 -ac_reward=25600000000 -ac_halving=77777 -ac_private=1 -addnode=136.243.102.225 & From 426efacd34ea8d526e47f2d6cc9328ba0c06349b Mon Sep 17 00:00:00 2001 From: SHossain Date: Sun, 23 Sep 2018 20:55:23 +0100 Subject: [PATCH 012/135] Update dpowassets --- src/dpowassets | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dpowassets b/src/dpowassets index f691533ba..2b85f976f 100755 --- a/src/dpowassets +++ b/src/dpowassets @@ -41,3 +41,4 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dp curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"SEC\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CCL\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"HUSH\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PIRATE\",\"pubkey\":\"$pubkey\"}" From 40027428e40b1026f20ae17683d8e9f11ccac0d7 Mon Sep 17 00:00:00 2001 From: himu007 Date: Sun, 23 Sep 2018 21:52:56 +0100 Subject: [PATCH 013/135] add PIRATE --- src/ac/pirate | 2 ++ src/assetchains.json | 4 ++-- src/assetchains.old | 1 + src/fiat/pirate | 2 ++ 4 files changed, 7 insertions(+), 2 deletions(-) create mode 100755 src/ac/pirate create mode 100755 src/fiat/pirate diff --git a/src/ac/pirate b/src/ac/pirate new file mode 100755 index 000000000..9314209da --- /dev/null +++ b/src/ac/pirate @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=PIRATE $1 $2 $3 $4 $5 $6 diff --git a/src/assetchains.json b/src/assetchains.json index 0a9a6b93c..825f606df 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -145,8 +145,8 @@ "142.93.136.89", "195.201.22.89" ] - } - { + }, + { "ac_name": "PIRATE", "ac_supply": "0", "ac_reward": "25600000000", diff --git a/src/assetchains.old b/src/assetchains.old index 2e9218d64..96f680b03 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -40,3 +40,4 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=SEC -ac_cc=333 -ac_supply=1000000000 -addnode=185.148.145.43 & ./komodod -pubkey=$pubkey -ac_name=CCL -ac_supply=200000000 -ac_end=1 -ac_cc=2 -addressindex=1 -spentindex=1 -addnode=142.93.136.89 -addnode=195.201.22.89 & ./komodod -pubkey=$pubkey -ac_name=PIRATE -ac_supply=0 -ac_reward=25600000000 -ac_halving=77777 -ac_private=1 -addnode=136.243.102.225 & + diff --git a/src/fiat/pirate b/src/fiat/pirate new file mode 100755 index 000000000..9314209da --- /dev/null +++ b/src/fiat/pirate @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=PIRATE $1 $2 $3 $4 $5 $6 From 594c9d12748b958f4c0a768fb522ae902bbc161f Mon Sep 17 00:00:00 2001 From: Jorian Date: Mon, 24 Sep 2018 15:41:03 +0200 Subject: [PATCH 014/135] add mgnx --- src/ac/mgnx | 2 ++ src/assetchains.json | 12 ++++++++++++ src/assetchains.old | 2 +- src/dpowassets | 1 + src/fiat/mgnx | 2 ++ 5 files changed, 18 insertions(+), 1 deletion(-) create mode 100755 src/ac/mgnx create mode 100755 src/fiat/mgnx diff --git a/src/ac/mgnx b/src/ac/mgnx new file mode 100755 index 000000000..9bd85336e --- /dev/null +++ b/src/ac/mgnx @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=MGNX $1 $2 $3 $4 $5 $6 diff --git a/src/assetchains.json b/src/assetchains.json index 825f606df..7dbd7a473 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -155,5 +155,17 @@ "addnode": [ "136.243.102.225" ] + }, + { + "ac_name": "MGNX", + "ac_supply": "12465003", + "ac_staked": "90", + "ac_reward": "2000000000", + "ac_halving": "525960", + "ac_cc": "2", + "ac_end": "2629800", + "addnode": [ + "45.76.32.178" + ] } ] diff --git a/src/assetchains.old b/src/assetchains.old index 96f680b03..fcee4bf41 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -40,4 +40,4 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=SEC -ac_cc=333 -ac_supply=1000000000 -addnode=185.148.145.43 & ./komodod -pubkey=$pubkey -ac_name=CCL -ac_supply=200000000 -ac_end=1 -ac_cc=2 -addressindex=1 -spentindex=1 -addnode=142.93.136.89 -addnode=195.201.22.89 & ./komodod -pubkey=$pubkey -ac_name=PIRATE -ac_supply=0 -ac_reward=25600000000 -ac_halving=77777 -ac_private=1 -addnode=136.243.102.225 & - +./komodod -pubkey=$pubkey -ac_name=MGNX -ac_supply=12465003 -ac_staked=90 -ac_reward=2000000000 -ac_halving=525960 -ac_cc=2 -ac_end=2629800 -addnode=142.93.27.180 & diff --git a/src/dpowassets b/src/dpowassets index 2b85f976f..9bd17ff18 100755 --- a/src/dpowassets +++ b/src/dpowassets @@ -42,3 +42,4 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dp curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CCL\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"HUSH\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PIRATE\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MGNX\",\"pubkey\":\"$pubkey\"}" diff --git a/src/fiat/mgnx b/src/fiat/mgnx new file mode 100755 index 000000000..9bd85336e --- /dev/null +++ b/src/fiat/mgnx @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=MGNX $1 $2 $3 $4 $5 $6 From 966a1680374b22754393a4ed844743d6e9036512 Mon Sep 17 00:00:00 2001 From: Jorian Date: Mon, 24 Sep 2018 15:43:16 +0200 Subject: [PATCH 015/135] fix ip --- src/assetchains.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assetchains.json b/src/assetchains.json index 7dbd7a473..f78e19f87 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -165,7 +165,7 @@ "ac_cc": "2", "ac_end": "2629800", "addnode": [ - "45.76.32.178" + "142.93.27.180" ] } ] From e47eab188b702815dc45035329141125cb1b9265 Mon Sep 17 00:00:00 2001 From: SHossain Date: Sun, 30 Sep 2018 20:03:52 +0100 Subject: [PATCH 016/135] Update README.md --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e8ed8c3cb..9585c7f78 100644 --- a/README.md +++ b/README.md @@ -10,13 +10,14 @@ This is the official Komodo sourcecode repository based on https://github.com/jl ## Development Resources - Komodo Website: [https://komodoplatform.com/](https://komodoplatform.com/) -- Komodo Blockexplorer: [https://kmdexplorer.io//](https://https://kmdexplorer.io/) +- Komodo Blockexplorer: [https://kmdexplorer.io//](https://kmdexplorer.io/) +- Komodo Discord: [https://komodoplatform.com/discord](https://komodoplatform.com/discord) - Forum: [https://forum.komodoplatform.com/](https://forum.komodoplatform.com/) - Mail: [info@komodoplatform.com](mailto:info@komodoplatform.com) - Support: [https://support.komodoplatform.com/support/home](https://support.komodoplatform.com/support/home) -- Knowledgebase & How-to: [https://komodoplatform.atlassian.net/wiki/spaces/KPSD/pages](https://komodoplatform.atlassian.net/wiki/spaces/KPSD/pages) -- API references: [http://docs.komodoplatform.com/](http://docs.komodoplatform.com/) -- Blog: [http://blog.komodoplatform.com/](http://blog.komodoplatform.com/) +- Knowledgebase & How-to: [https://support.komodoplatform.com/en/support/solutions](https://support.komodoplatform.com/en/support/solutions) +- API references & Dev Documentation: [https://docs.komodoplatform.com/](https://docs.komodoplatform.com/) +- Blog: [https://blog.komodoplatform.com/](https://blog.komodoplatform.com/) - Whitepaper: [Komodo Whitepaper](https://komodoplatform.com/wp-content/uploads/2018/03/2018-03-12-Komodo-White-Paper-Full.pdf) - Komodo Platform public material: [Komodo Platform public material](https://docs.google.com/document/d/1AbhWrtagu4vYdkl-vsWz-HSNyNvK-W-ZasHCqe7CZy0) From 5ca814d52dee0070944224b9e1a1ce5356b270a5 Mon Sep 17 00:00:00 2001 From: SHossain Date: Mon, 1 Oct 2018 10:52:36 +0100 Subject: [PATCH 017/135] Update README.md --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 9585c7f78..92a7014f4 100644 --- a/README.md +++ b/README.md @@ -9,16 +9,16 @@ This is the official Komodo sourcecode repository based on https://github.com/jl ## Development Resources -- Komodo Website: [https://komodoplatform.com/](https://komodoplatform.com/) -- Komodo Blockexplorer: [https://kmdexplorer.io//](https://kmdexplorer.io/) +- Komodo Website: [https://komodoplatform.com](https://komodoplatform.com/) +- Komodo Blockexplorer: [https://kmdexplorer.io](https://kmdexplorer.io/) - Komodo Discord: [https://komodoplatform.com/discord](https://komodoplatform.com/discord) -- Forum: [https://forum.komodoplatform.com/](https://forum.komodoplatform.com/) +- Forum: [https://forum.komodoplatform.com](https://forum.komodoplatform.com/) - Mail: [info@komodoplatform.com](mailto:info@komodoplatform.com) - Support: [https://support.komodoplatform.com/support/home](https://support.komodoplatform.com/support/home) - Knowledgebase & How-to: [https://support.komodoplatform.com/en/support/solutions](https://support.komodoplatform.com/en/support/solutions) -- API references & Dev Documentation: [https://docs.komodoplatform.com/](https://docs.komodoplatform.com/) -- Blog: [https://blog.komodoplatform.com/](https://blog.komodoplatform.com/) -- Whitepaper: [Komodo Whitepaper](https://komodoplatform.com/wp-content/uploads/2018/03/2018-03-12-Komodo-White-Paper-Full.pdf) +- API references & Dev Documentation: [https://docs.komodoplatform.com](https://docs.komodoplatform.com/) +- Blog: [https://blog.komodoplatform.com](https://blog.komodoplatform.com/) +- Whitepaper: [Komodo Whitepaper](https://komodoplatform.com/whitepaper) - Komodo Platform public material: [Komodo Platform public material](https://docs.google.com/document/d/1AbhWrtagu4vYdkl-vsWz-HSNyNvK-W-ZasHCqe7CZy0) ## List of Komodo Platform Technologies From 4c95cd4c6fa863f6b3f9c72eb93de9040e645091 Mon Sep 17 00:00:00 2001 From: SHossain Date: Tue, 2 Oct 2018 14:13:58 +0100 Subject: [PATCH 018/135] Update dpowassets --- src/dpowassets | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dpowassets b/src/dpowassets index 9bd17ff18..40bf0e624 100755 --- a/src/dpowassets +++ b/src/dpowassets @@ -43,3 +43,4 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dp curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"HUSH\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PIRATE\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MGNX\",\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"EMC2\",\"freq\":10,\"pubkey\":\"$pubkey\"}" From eb94acf7337d4b3a701527902fe71fed55e0a70e Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Sun, 7 Oct 2018 17:06:27 +0300 Subject: [PATCH 019/135] + freq:5 for EMC2 --- src/dpowassets | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dpowassets b/src/dpowassets index 40bf0e624..2e74f9de3 100755 --- a/src/dpowassets +++ b/src/dpowassets @@ -43,4 +43,4 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dp curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"HUSH\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PIRATE\",\"pubkey\":\"$pubkey\"}" curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MGNX\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"EMC2\",\"freq\":10,\"pubkey\":\"$pubkey\"}" +curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"EMC2\",\"freq\":5,\"pubkey\":\"$pubkey\"}" From b32790aed80987ab0fc8ba3c184ad4061b74312a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 8 Oct 2018 09:08:55 -1100 Subject: [PATCH 020/135] -dpowassets --- src/dpowassets | 42 ------------------------------------------ 1 file changed, 42 deletions(-) delete mode 100755 src/dpowassets diff --git a/src/dpowassets b/src/dpowassets deleted file mode 100755 index 88e6f72b8..000000000 --- a/src/dpowassets +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/bash -set -x -source pubkey.txt -echo $pubkey -sleep 3 - -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"REVS\",\"pubkey\":\"$pubkey\"}" - -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"SUPERNET\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"DEX\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PANGEA\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"JUMBLR\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BET\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CRYPTO\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"HODL\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MSHARK\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BOTS\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MGW\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"COQUI\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"WLC\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"KV\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CEAL\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MESH\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MNZ\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"AXO\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"ETOMIC\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BTCH\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CHAIN\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"NINJA\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"OOT\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BNTN\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PRLPAY\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"DSEC\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"GLXT\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"EQL\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"ZILLA\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CHIPS\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"GAME\",\"freq\":5,\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"RFOX\",\"freq\":10,\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"VRSC\",\"freq\":10,\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"SEC\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CCL\",\"pubkey\":\"$pubkey\"}" From e3eea615467a985aba205f23fe2e7ea59e7e658a Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 8 Oct 2018 09:09:23 -1100 Subject: [PATCH 021/135] -dpowassets --- src/dpowassets | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) delete mode 100755 src/dpowassets diff --git a/src/dpowassets b/src/dpowassets deleted file mode 100755 index 2e74f9de3..000000000 --- a/src/dpowassets +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/bash -set -x -source pubkey.txt -echo $pubkey -sleep 3 - -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"REVS\",\"pubkey\":\"$pubkey\"}" - -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"SUPERNET\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"DEX\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PANGEA\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"JUMBLR\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BET\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CRYPTO\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"HODL\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MSHARK\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BOTS\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MGW\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"COQUI\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"WLC\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"KV\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CEAL\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MESH\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MNZ\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"AXO\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"ETOMIC\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BTCH\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CHAIN\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"NINJA\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"OOT\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"BNTN\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PRLPAY\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"DSEC\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"GLXT\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"EQL\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"ZILLA\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CHIPS\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"GAME\",\"freq\":5,\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"RFOX\",\"freq\":10,\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"VRSC\",\"freq\":10,\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"SEC\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CCL\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"HUSH\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PIRATE\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"MGNX\",\"pubkey\":\"$pubkey\"}" -curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"EMC2\",\"freq\":5,\"pubkey\":\"$pubkey\"}" From 3cc05dc7b84b59ed9776d30565da20ca607be941 Mon Sep 17 00:00:00 2001 From: Mihail Fedorov Date: Thu, 11 Oct 2018 04:07:04 +0300 Subject: [PATCH 022/135] PGT --- src/ac/pgt | 2 ++ src/assetchains.json | 8 ++++++++ src/assetchains.old | 1 + src/fiat/pgt | 2 ++ 4 files changed, 13 insertions(+) create mode 100755 src/ac/pgt create mode 100755 src/fiat/pgt diff --git a/src/ac/pgt b/src/ac/pgt new file mode 100755 index 000000000..8e124bbd1 --- /dev/null +++ b/src/ac/pgt @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=PGT $1 $2 $3 $4 $5 $6 diff --git a/src/assetchains.json b/src/assetchains.json index f78e19f87..fb20b2cba 100644 --- a/src/assetchains.json +++ b/src/assetchains.json @@ -167,5 +167,13 @@ "addnode": [ "142.93.27.180" ] + }, +{ + "ac_name": "PGT", + "ac_supply": "10000000", + "ac_end": "1", + "addnode": [ + "190.114.254.104" + ] } ] diff --git a/src/assetchains.old b/src/assetchains.old index fcee4bf41..12c743d1d 100755 --- a/src/assetchains.old +++ b/src/assetchains.old @@ -41,3 +41,4 @@ echo $pubkey ./komodod -pubkey=$pubkey -ac_name=CCL -ac_supply=200000000 -ac_end=1 -ac_cc=2 -addressindex=1 -spentindex=1 -addnode=142.93.136.89 -addnode=195.201.22.89 & ./komodod -pubkey=$pubkey -ac_name=PIRATE -ac_supply=0 -ac_reward=25600000000 -ac_halving=77777 -ac_private=1 -addnode=136.243.102.225 & ./komodod -pubkey=$pubkey -ac_name=MGNX -ac_supply=12465003 -ac_staked=90 -ac_reward=2000000000 -ac_halving=525960 -ac_cc=2 -ac_end=2629800 -addnode=142.93.27.180 & +./komodod -pubkey=$pubkey -ac_name=PGT -ac_supply=10000000 -ac_end=1 -addnode=190.114.254.104 & diff --git a/src/fiat/pgt b/src/fiat/pgt new file mode 100755 index 000000000..8e124bbd1 --- /dev/null +++ b/src/fiat/pgt @@ -0,0 +1,2 @@ +#!/bin/bash +./komodo-cli -ac_name=PGT $1 $2 $3 $4 $5 $6 From 96073d7981d23300bcdcf205ab93ba263afa783f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 01:07:16 -1100 Subject: [PATCH 023/135] -ac_founders --- src/komodo_bitcoind.h | 19 ++++++++++++++----- src/komodo_globals.h | 2 +- src/komodo_utils.h | 28 ++++++++++++++++++++++------ 3 files changed, 37 insertions(+), 12 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 76216efee..553b7dea4 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1110,14 +1110,23 @@ uint64_t komodo_commission(const CBlock *pblock) { int32_t i,j,n=0,txn_count; uint64_t commission,total = 0; txn_count = pblock->vtx.size(); - for (i=0; ivtx[i].vout.size(); + n = pblock->vtx[0].vout.size(); for (j=0; jvtx[i].vout[j].nValue; + } + else + { + for (i=0; ivtx[i].vout[j].nValue; + n = pblock->vtx[i].vout.size(); + for (j=0; jvtx[i].vout[j].nValue; + } } } //fprintf(stderr,"txn.%d n.%d commission total %.8f -> %.8f\n",txn_count,n,dstr(total),dstr((total * ASSETCHAINS_COMMISSION) / COIN)); diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 6d0b10328..057fec6c6 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -48,7 +48,7 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; -uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW; +uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_FOUNDERS; char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096]; uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index dd7082ffa..50f3ac651 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1555,6 +1555,7 @@ void komodo_args(char *argv0) { MAX_BLOCK_SIGOPS = 60000; ASSETCHAINS_TXPOW = GetArg("-ac_txpow",0) & 3; + ASSETCHAINS_FOUNDERS = GetArg("-ac_founders",0) & 1; ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); ASSETCHAINS_ENDSUBSIDY = GetArg("-ac_end",0); ASSETCHAINS_REWARD = GetArg("-ac_reward",0); @@ -1585,13 +1586,28 @@ void komodo_args(char *argv0) printf("ASSETCHAINS_DECAY cant be more than 100000000\n"); } if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 ) - decode_hex(ASSETCHAINS_OVERRIDE_PUBKEY33,33,(char *)ASSETCHAINS_OVERRIDE_PUBKEY.c_str()); - else if ( ASSETCHAINS_COMMISSION != 0 ) { - ASSETCHAINS_COMMISSION = 0; - printf("ASSETCHAINS_COMMISSION needs an ASETCHAINS_OVERRIDE_PUBKEY and cant be more than 100000000 (100%%)\n"); + decode_hex(ASSETCHAINS_OVERRIDE_PUBKEY33,33,(char *)ASSETCHAINS_OVERRIDE_PUBKEY.c_str()); + if ( ASSETCHAINS_COMMISSION == 0 && ASSETCHAINS_FOUNDERS != 0 ) + { + ASSETCHAINS_COMMISSION = 35000000; + printf("ASSETCHAINS_COMMISSION defaulted to 35% when founders reward active\n"); + } } - if ( ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 ) + else + { + if ( ASSETCHAINS_COMMISSION != 0 ) + { + ASSETCHAINS_COMMISSION = 0; + printf("ASSETCHAINS_COMMISSION needs an ASETCHAINS_OVERRIDE_PUBKEY and cant be more than 100000000 (100%%)\n"); + } + if ( ASSETCHAINS_FOUNDERS != 0 ) + { + ASSETCHAINS_FOUNDERS = 0; + printf("ASSETCHAINS_FOUNDERS needs an ASETCHAINS_OVERRIDE_PUBKEY\n"); + } + } + if ( ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 ) { fprintf(stderr,"end.%llu blocks, reward %.8f halving.%llu blocks, decay.%llu perc %.4f%% ac_pub=[%02x...]\n",(long long)ASSETCHAINS_ENDSUBSIDY,dstr(ASSETCHAINS_REWARD),(long long)ASSETCHAINS_HALVING,(long long)ASSETCHAINS_DECAY,dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0]); extraptr = extrabuf; @@ -1600,7 +1616,7 @@ void komodo_args(char *argv0) extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_REWARD),(void *)&ASSETCHAINS_REWARD); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_HALVING),(void *)&ASSETCHAINS_HALVING); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_DECAY),(void *)&ASSETCHAINS_DECAY); - val = ASSETCHAINS_COMMISSION | (((uint64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | ((ASSETCHAINS_PUBLIC != 0) << 7) | ((ASSETCHAINS_PRIVATE != 0) << 6) | ASSETCHAINS_TXPOW; + val = ASSETCHAINS_COMMISSION | (((uint64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | ((ASSETCHAINS_PUBLIC != 0) << 7) | ((ASSETCHAINS_PRIVATE != 0) << 6) | ASSETCHAINS_TXPOW || (ASSETCHAINS_FOUNDERS & 1) << 2); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val); } addn = GetArg("-seednode",""); From 6bbd32f7bb1013137c77f2378056af2f98b7761a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 01:13:22 -1100 Subject: [PATCH 024/135] ( --- src/komodo_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 50f3ac651..bb447a4d3 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1591,7 +1591,7 @@ void komodo_args(char *argv0) if ( ASSETCHAINS_COMMISSION == 0 && ASSETCHAINS_FOUNDERS != 0 ) { ASSETCHAINS_COMMISSION = 35000000; - printf("ASSETCHAINS_COMMISSION defaulted to 35% when founders reward active\n"); + printf("ASSETCHAINS_COMMISSION defaulted to 35%% when founders reward active\n"); } } else @@ -1616,7 +1616,7 @@ void komodo_args(char *argv0) extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_REWARD),(void *)&ASSETCHAINS_REWARD); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_HALVING),(void *)&ASSETCHAINS_HALVING); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_DECAY),(void *)&ASSETCHAINS_DECAY); - val = ASSETCHAINS_COMMISSION | (((uint64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | ((ASSETCHAINS_PUBLIC != 0) << 7) | ((ASSETCHAINS_PRIVATE != 0) << 6) | ASSETCHAINS_TXPOW || (ASSETCHAINS_FOUNDERS & 1) << 2); + val = ASSETCHAINS_COMMISSION | (((uint64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | ((ASSETCHAINS_PUBLIC != 0) << 7) | ((ASSETCHAINS_PRIVATE != 0) << 6) | ASSETCHAINS_TXPOW || ((ASSETCHAINS_FOUNDERS & 1) << 2); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val); } addn = GetArg("-seednode",""); From 0b4e6bb9f82b1906e458ab450599d65ab8cdb77c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 01:39:59 -1100 Subject: [PATCH 025/135] Min MAX_MONEY for CC chains, set to 1 million --- src/komodo_utils.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index bb447a4d3..ef0bbb75f 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1629,6 +1629,8 @@ void komodo_args(char *argv0) MAX_MONEY = (ASSETCHAINS_SUPPLY+100) * SATOSHIDEN; else MAX_MONEY = (ASSETCHAINS_SUPPLY+100) * SATOSHIDEN + ASSETCHAINS_REWARD * (ASSETCHAINS_ENDSUBSIDY==0 ? 10000000 : ASSETCHAINS_ENDSUBSIDY); MAX_MONEY += (MAX_MONEY * ASSETCHAINS_COMMISSION) / SATOSHIDEN; + if ( ASSETCHAINS_CC != 0 && MAX_MONEY < 1000000LL*COIN ) + MAX_MONEY = 1000000LL*COIN; //printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN); ASSETCHAINS_P2PPORT = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen); while ( (dirname= (char *)GetDataDir(false).string().c_str()) == 0 || dirname[0] == 0 ) From 4c19084cd7b512bbc0c597ed4d7ac9d7df315045 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 01:45:04 -1100 Subject: [PATCH 026/135] SATOSHIDEN --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index ef0bbb75f..d71b8cbee 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1629,7 +1629,7 @@ void komodo_args(char *argv0) MAX_MONEY = (ASSETCHAINS_SUPPLY+100) * SATOSHIDEN; else MAX_MONEY = (ASSETCHAINS_SUPPLY+100) * SATOSHIDEN + ASSETCHAINS_REWARD * (ASSETCHAINS_ENDSUBSIDY==0 ? 10000000 : ASSETCHAINS_ENDSUBSIDY); MAX_MONEY += (MAX_MONEY * ASSETCHAINS_COMMISSION) / SATOSHIDEN; - if ( ASSETCHAINS_CC != 0 && MAX_MONEY < 1000000LL*COIN ) + if ( ASSETCHAINS_CC != 0 && MAX_MONEY < 1000000LL*SATOSHIDEN ) MAX_MONEY = 1000000LL*COIN; //printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN); ASSETCHAINS_P2PPORT = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen); From 10b571ddfde5ab482a1183b24c1090465748c69e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 01:46:45 -1100 Subject: [PATCH 027/135] Fix --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index d71b8cbee..9ceb69f78 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1630,7 +1630,7 @@ void komodo_args(char *argv0) else MAX_MONEY = (ASSETCHAINS_SUPPLY+100) * SATOSHIDEN + ASSETCHAINS_REWARD * (ASSETCHAINS_ENDSUBSIDY==0 ? 10000000 : ASSETCHAINS_ENDSUBSIDY); MAX_MONEY += (MAX_MONEY * ASSETCHAINS_COMMISSION) / SATOSHIDEN; if ( ASSETCHAINS_CC != 0 && MAX_MONEY < 1000000LL*SATOSHIDEN ) - MAX_MONEY = 1000000LL*COIN; + MAX_MONEY = 1000000LL*SATOSHIDEN; //printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN); ASSETCHAINS_P2PPORT = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen); while ( (dirname= (char *)GetDataDir(false).string().c_str()) == 0 || dirname[0] == 0 ) From a2c903014097346206138bf2e2c64fb0bd7ea63d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 01:55:36 -1100 Subject: [PATCH 028/135] if ( ASSETCHAINS_CC >= KOMODO_FIRSTFUNGIBLEID && MAX_MONEY < 1000000LL*SATOSHIDEN ) --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 9ceb69f78..d1c927787 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1629,7 +1629,7 @@ void komodo_args(char *argv0) MAX_MONEY = (ASSETCHAINS_SUPPLY+100) * SATOSHIDEN; else MAX_MONEY = (ASSETCHAINS_SUPPLY+100) * SATOSHIDEN + ASSETCHAINS_REWARD * (ASSETCHAINS_ENDSUBSIDY==0 ? 10000000 : ASSETCHAINS_ENDSUBSIDY); MAX_MONEY += (MAX_MONEY * ASSETCHAINS_COMMISSION) / SATOSHIDEN; - if ( ASSETCHAINS_CC != 0 && MAX_MONEY < 1000000LL*SATOSHIDEN ) + if ( ASSETCHAINS_CC >= KOMODO_FIRSTFUNGIBLEID && MAX_MONEY < 1000000LL*SATOSHIDEN ) MAX_MONEY = 1000000LL*SATOSHIDEN; //printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN); ASSETCHAINS_P2PPORT = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen); From 9a4e737db3b21ad01f7750d154019289551b3bf2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 01:57:22 -1100 Subject: [PATCH 029/135] #define KOMODO_FIRSTFUNGIBLEID 100 --- src/komodo_defs.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_defs.h b/src/komodo_defs.h index 1efd187d9..ca9a05c37 100644 --- a/src/komodo_defs.h +++ b/src/komodo_defs.h @@ -9,6 +9,7 @@ #define IGUANA_MAXSCRIPTSIZE 10001 #define KOMODO_MAXMEMPOOLTIME 3600 // affects consensus #define CRYPTO777_PUBSECPSTR "020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9" +#define KOMODO_FIRSTFUNGIBLEID 100 extern uint8_t ASSETCHAINS_TXPOW; From 27a25b20731924ad8f97c3ffd0b369aa666b4606 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 02:06:04 -1100 Subject: [PATCH 030/135] Allow p2pkh for ac_pubkey chains --- src/komodo_bitcoind.h | 3 +++ src/komodo_globals.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 553b7dea4..ae16d513c 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1482,7 +1482,10 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) { script = (uint8_t *)pblock->vtx[0].vout[1].scriptPubKey.data(); if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) + { + if ( script[0] != 25 || script[0] != OP_DUP || script[1] != OP_HASH160 || script[23] != OP_EQUALVERIFY || script[24] != OP_CHECKSIG || memcmp(script+2,ASSETCHAINS_OVERRIDE_PUBKEYHASH,20) != 0 ) return(-1); + } if ( pblock->vtx[0].vout[1].nValue != checktoshis ) { fprintf(stderr,"ht.%d checktoshis %.8f vs actual vout[1] %.8f\n",height,dstr(checktoshis),dstr(pblock->vtx[0].vout[1].nValue)); diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 057fec6c6..78f1e1cac 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -48,7 +48,7 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; -uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_FOUNDERS; +uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_FOUNDERS; char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096]; uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; From c29bc5d02e608c2eb02c45b63164a04cb2b002a2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 02:10:11 -1100 Subject: [PATCH 031/135] Calculate rmd160 for ac_pubkey --- src/komodo_utils.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index d1c927787..2e0c45549 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1588,6 +1588,7 @@ void komodo_args(char *argv0) if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 ) { decode_hex(ASSETCHAINS_OVERRIDE_PUBKEY33,33,(char *)ASSETCHAINS_OVERRIDE_PUBKEY.c_str()); + calc_rmd160_sha256(ASSETCHAINS_OVERRIDE_PUBKEYHASH,ASSETCHAINS_OVERRIDE_PUBKEY33,33); if ( ASSETCHAINS_COMMISSION == 0 && ASSETCHAINS_FOUNDERS != 0 ) { ASSETCHAINS_COMMISSION = 35000000; From 8cb45c21edf50cc470179b78244f8420181b0119 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 02:27:37 -1100 Subject: [PATCH 032/135] Test --- src/komodo_utils.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 2e0c45549..265f79248 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1617,8 +1617,10 @@ void komodo_args(char *argv0) extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_REWARD),(void *)&ASSETCHAINS_REWARD); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_HALVING),(void *)&ASSETCHAINS_HALVING); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_DECAY),(void *)&ASSETCHAINS_DECAY); - val = ASSETCHAINS_COMMISSION | (((uint64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | ((ASSETCHAINS_PUBLIC != 0) << 7) | ((ASSETCHAINS_PRIVATE != 0) << 6) | ASSETCHAINS_TXPOW || ((ASSETCHAINS_FOUNDERS & 1) << 2); + val = ASSETCHAINS_COMMISSION | (((uint64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | ((ASSETCHAINS_PUBLIC != 0) << 7) | ((ASSETCHAINS_PRIVATE != 0) << 6) | ASSETCHAINS_TXPOW); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val); + if ( ASSETCHAINS_FOUNDERS != 0 ) + extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS),(void *)&ASSETCHAINS_FOUNDERS); } addn = GetArg("-seednode",""); if ( strlen(addn.c_str()) > 0 ) From 093f5ffa73a57332ae61ac9412d014ff0195ff0a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 02:29:55 -1100 Subject: [PATCH 033/135] Test --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 265f79248..8fb50c23e 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1617,7 +1617,7 @@ void komodo_args(char *argv0) extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_REWARD),(void *)&ASSETCHAINS_REWARD); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_HALVING),(void *)&ASSETCHAINS_HALVING); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_DECAY),(void *)&ASSETCHAINS_DECAY); - val = ASSETCHAINS_COMMISSION | (((uint64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | ((ASSETCHAINS_PUBLIC != 0) << 7) | ((ASSETCHAINS_PRIVATE != 0) << 6) | ASSETCHAINS_TXPOW); + val = ASSETCHAINS_COMMISSION | (((uint64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | ((ASSETCHAINS_PUBLIC != 0) << 7) | ((ASSETCHAINS_PRIVATE != 0) << 6) | ASSETCHAINS_TXPOW; extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val); if ( ASSETCHAINS_FOUNDERS != 0 ) extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS),(void *)&ASSETCHAINS_FOUNDERS); From 6c1588f663491ad7028bd5a5e5b2234fc1be900b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 02:57:18 -1100 Subject: [PATCH 034/135] Entropyvout --- src/cc/dice.cpp | 74 ++++++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 34 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 0316384ab..05f448550 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -104,6 +104,7 @@ extern int32_t KOMODO_INSYNC; static uint256 bettxids[MAX_ENTROPYUSED],entropytxids[MAX_ENTROPYUSED][2]; // change to hashtable static CTransaction betTxs[MAX_ENTROPYUSED]; +static int32_t entropyvouts[MAX_ENTROPYUSED]; pthread_mutex_t DICE_MUTEX,DICEREVEALED_MUTEX; @@ -115,7 +116,7 @@ struct dicefinish_info uint256 fundingtxid,bettxid,entropyused,txid; uint64_t sbits; int64_t winamount; - int32_t iswin; + int32_t iswin,entropyvout; uint32_t bettxid_ready,revealed; CTransaction betTx; std::string rawtx; @@ -155,25 +156,26 @@ void _dicehash_add(uint256 bettxid) bettxids[rand() % MAX_ENTROPYUSED] = bettxid; } -int32_t _dicerevealed_find(uint256 &oldbettxid,CTransaction &oldbetTx,uint256 entropyused,uint256 bettxid) +int32_t _dicerevealed_find(uint256 &oldbettxid,CTransaction &oldbetTx,int32_t &oldentropyvout,uint256 entropyused,uint256 bettxid,int32_t entropyvout) { int32_t i; for (i=0; i 64 && is_hexstr((char *)res.c_str(),0) > 64 ) { if ( DecodeHexTx(tx,res) != 0 ) @@ -213,7 +216,7 @@ bool mySenddicetransaction(std::string res,uint256 entropyused,uint256 bettxid,C if ( ptr != 0 ) ptr->txid = tx.GetHash(); //fprintf(stderr,"%s\n%s\n",res.c_str(),uint256_str(str,tx.GetHash())); - if ( funcid == 'R' || (retval= DiceEntropyUsed(oldbetTx,oldbettxid,entropyused,bettxid,betTx)) >= 0 ) + if ( funcid == 'R' || (retval= DiceEntropyUsed(oldbetTx,oldbettxid,oldentropyvout,entropyused,bettxid,betTx,entropyvout)) >= 0 ) { //LOCK(cs_main); if ( myAddtomempool(tx) != 0 ) @@ -371,7 +374,7 @@ void *dicefinish(void *_ptr) CCduration(numblocks,ptr->txid); fprintf(stderr,"duration finish txid.%s\n",ptr->txid.GetHex().c_str()); if ( numblocks == 0 ) - mySenddicetransaction(ptr->rawtx,ptr->entropyused,ptr->bettxid,ptr->betTx,ptr->funcid,ptr); + mySenddicetransaction(ptr->rawtx,ptr->entropyused,ptr->entropyvout,ptr->bettxid,ptr->betTx,ptr->funcid,ptr); else continue; } if ( ptr->txid == zeroid ) @@ -408,11 +411,11 @@ void *dicefinish(void *_ptr) { unstringbits(name,ptr->sbits); result = 0; - res = DiceBetFinish(ptr->funcid,ptr->entropyused,&result,0,name,ptr->fundingtxid,ptr->bettxid,ptr->iswin,utxos[m].txid,utxos[m].vout); + res = DiceBetFinish(ptr->funcid,ptr->entropyused,ptr->entropyvout,&result,0,name,ptr->fundingtxid,ptr->bettxid,ptr->iswin,utxos[m].txid,utxos[m].vout); if ( result > 0 ) { ptr->rawtx = res; - mySenddicetransaction(ptr->rawtx,ptr->entropyused,ptr->bettxid,ptr->betTx,ptr->funcid,ptr); + mySenddicetransaction(ptr->rawtx,ptr->entropyused,ptr->entropyvout,ptr->bettxid,ptr->betTx,ptr->funcid,ptr); } else if ( result != -2 ) { @@ -457,7 +460,7 @@ void *dicefinish(void *_ptr) return(0); } -void DiceQueue(int32_t iswin,uint64_t sbits,uint256 fundingtxid,uint256 bettxid,CTransaction betTx) +void DiceQueue(int32_t iswin,uint64_t sbits,uint256 fundingtxid,uint256 bettxid,CTransaction betTx,int32_t entropyvout) { static int32_t didinit; struct dicefinish_info *ptr; int32_t i,duplicate=0; uint64_t txfee = 10000; @@ -488,6 +491,7 @@ void DiceQueue(int32_t iswin,uint64_t sbits,uint256 fundingtxid,uint256 bettxid, ptr->sbits = sbits; ptr->iswin = iswin; ptr->winamount = betTx.vout[1].nValue * ((betTx.vout[2].nValue - txfee)+1); + ptr->entropyvout = entropyvout; DL_APPEND(DICEFINISH_LIST,ptr); fprintf(stderr,"queued iswin.%d %.8f -> %.8f %s\n",iswin,(double)betTx.vout[1].nValue/COIN,(double)ptr->winamount/COIN,bettxid.GetHex().c_str()); } @@ -512,7 +516,7 @@ CPubKey DiceFundingPk(CScript scriptPubKey) return(pk); } -uint256 DiceHashEntropy(uint256 &entropy,uint256 _txidpriv) // max 1 vout per txid used +uint256 DiceHashEntropy(uint256 &entropy,uint256 _txidpriv,int32_t vout) { int32_t i; uint8_t _entropy[32],_hentropy[32]; bits256 tmp256,txidpub,txidpriv,mypriv,mypub,ssecret,ssecret2; uint256 hentropy; memset(&hentropy,0,32); @@ -741,7 +745,7 @@ bool DiceIsmine(const CScript scriptPubKey) return(strcmp(destaddr,myaddr) == 0); } -int32_t DiceIsWinner(uint256 &entropy,uint256 txid,CTransaction tx,CTransaction vinTx,uint256 bettorentropy,uint64_t sbits,int64_t minbet,int64_t maxbet,int64_t maxodds,int64_t timeoutblocks,uint256 fundingtxid) +int32_t DiceIsWinner(uint256 &entropy,int32_t &entropyvout,uint256 txid,CTransaction tx,CTransaction vinTx,uint256 bettorentropy,uint64_t sbits,int64_t minbet,int64_t maxbet,int64_t maxodds,int64_t timeoutblocks,uint256 fundingtxid) { uint64_t vinsbits,winnings; uint256 vinproof,vinfundingtxid,hentropy,hentropy2; uint8_t funcid; //char str[65],str2[65]; @@ -749,7 +753,9 @@ int32_t DiceIsWinner(uint256 &entropy,uint256 txid,CTransaction tx,CTransaction { if ( ((funcid= DecodeDiceOpRet(txid,vinTx.vout[vinTx.vout.size()-1].scriptPubKey,vinsbits,vinfundingtxid,hentropy,vinproof)) == 'E' || funcid == 'W' || funcid == 'L') && sbits == vinsbits && fundingtxid == vinfundingtxid ) { - hentropy2 = DiceHashEntropy(entropy,vinTx.vin[0].prevout.hash); + hentropy2 = DiceHashEntropy(entropy,vinTx.vin[0].prevout.hash,vinTx.vin[0].prevout.n); + entropyvout = vinTx.vin[0].prevout.n; + fprintf(stderr,"bettxid %s -> vin0 %s/v%d -> %s\n",txid.GetHex().c_str(),vinTx.vin[0].prevout.hash.GetHex().c_str(),entropyvout,entropy.GetHex().c_str()); if ( hentropy == hentropy2 ) { winnings = DiceCalc(tx.vout[1].nValue,tx.vout[2].nValue,minbet,maxbet,maxodds,timeoutblocks,entropy,bettorentropy); @@ -781,7 +787,7 @@ bool DiceVerifyTimeout(CTransaction &betTx,int32_t timeoutblocks) bool DiceValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx) { - uint256 txid,fundingtxid,vinfundingtxid,vinhentropy,vinproof,hashBlock,hash,proof,entropy; int64_t minbet,maxbet,maxodds,timeoutblocks,odds,winnings; uint64_t vinsbits,refsbits=0,sbits,amount,inputs,outputs,txfee=10000; int32_t numvins,numvouts,preventCCvins,preventCCvouts,i,iswin; uint8_t funcid; CScript fundingPubKey; CTransaction fundingTx,vinTx,vinofvinTx; char CCaddr[64]; + uint256 txid,fundingtxid,vinfundingtxid,vinhentropy,vinproof,hashBlock,hash,proof,entropy; int64_t minbet,maxbet,maxodds,timeoutblocks,odds,winnings; uint64_t vinsbits,refsbits=0,sbits,amount,inputs,outputs,txfee=10000; int32_t numvins,entropyvout,numvouts,preventCCvins,preventCCvouts,i,iswin; uint8_t funcid; CScript fundingPubKey; CTransaction fundingTx,vinTx,vinofvinTx; char CCaddr[64]; numvins = tx.vin.size(); numvouts = tx.vout.size(); preventCCvins = preventCCvouts = -1; @@ -877,11 +883,11 @@ bool DiceValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx) } } } - if ( (iswin= DiceIsWinner(entropy,txid,tx,vinTx,hash,sbits,minbet,maxbet,maxodds,timeoutblocks,fundingtxid)) != 0 ) + if ( (iswin= DiceIsWinner(entropy,entropyvout,txid,tx,vinTx,hash,sbits,minbet,maxbet,maxodds,timeoutblocks,fundingtxid)) != 0 ) { // will only happen for fundingPubKey if ( KOMODO_INSYNC != 0 ) - DiceQueue(iswin,sbits,fundingtxid,txid,tx); + DiceQueue(iswin,sbits,fundingtxid,txid,tx,entropyvout); } else { @@ -1336,7 +1342,7 @@ std::string DiceAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,int6 { if ( AddNormalinputs(mtx,mypk,amount+2*txfee,1) > 0 ) { - hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash); + hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash,mtx.vin[0].prevout.n); mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,dicepk)); mtx.vout.push_back(CTxOut(txfee,fundingPubKey)); return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeDiceOpRet('E',sbits,fundingtxid,hentropy,zeroid))); @@ -1395,7 +1401,7 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet mtx.vin.push_back(CTxIn(entropytxid,0,CScript())); if ( AddNormalinputs(mtx,mypk,bet+2*txfee+odds,60) > 0 ) { - hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash); + hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash,mtx.vin[0].prevout.n); mtx.vout.push_back(MakeCC1vout(cp->evalcode,entropyval,dicepk)); mtx.vout.push_back(MakeCC1vout(cp->evalcode,bet,dicepk)); mtx.vout.push_back(CTxOut(txfee+odds,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); @@ -1409,9 +1415,9 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet return(""); } -std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t *resultp,uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettxid,int32_t winlosetimeout,uint256 vin0txid,int32_t vin0vout) +std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t &entropyvout,int32_t *resultp,uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettxid,int32_t winlosetimeout,uint256 vin0txid,int32_t vin0vout) { - CMutableTransaction mtx; CScript scriptPubKey,fundingPubKey; CTransaction oldbetTx,betTx,entropyTx; uint256 hentropyproof,entropytxid,hashBlock,bettorentropy,entropy,hentropy,oldbettxid; CPubKey mypk,dicepk,fundingpk; struct CCcontract_info *cp,C; int64_t inputs=0,CCchange=0,odds,fundsneeded,minbet,maxbet,maxodds,timeoutblocks; int32_t retval,iswin=0; uint64_t entropyval,sbits; + CMutableTransaction mtx; CScript scriptPubKey,fundingPubKey; CTransaction oldbetTx,betTx,entropyTx; uint256 hentropyproof,entropytxid,hashBlock,bettorentropy,entropy,hentropy,oldbettxid; CPubKey mypk,dicepk,fundingpk; struct CCcontract_info *cp,C; int64_t inputs=0,CCchange=0,odds,fundsneeded,minbet,maxbet,maxodds,timeoutblocks; int32_t oldentropyvout,entropyvout,retval,iswin=0; uint64_t entropyval,sbits; entropyused = zeroid; *resultp = 0; funcid = 0; @@ -1442,7 +1448,7 @@ std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t *resultp, return(""); }*/ bettorentropy = DiceGetEntropy(betTx,'B'); - if ( winlosetimeout == 0 || (iswin= DiceIsWinner(hentropyproof,bettxid,betTx,entropyTx,bettorentropy,sbits,minbet,maxbet,maxodds,timeoutblocks,fundingtxid)) != 0 ) + if ( winlosetimeout == 0 || (iswin= DiceIsWinner(hentropyproof,entropyvout,bettxid,betTx,entropyTx,bettorentropy,sbits,minbet,maxbet,maxodds,timeoutblocks,fundingtxid)) != 0 ) { if ( vin0txid == zeroid || vin0vout < 0 ) { @@ -1466,7 +1472,7 @@ std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t *resultp, retval = -1; fprintf(stderr,"invalid dicebet %s\n",bettxid.GetHex().c_str()); } else retval = 0;*/ - if ( (retval= DiceEntropyUsed(oldbetTx,oldbettxid,entropyused,bettxid,betTx)) != 0 ) + if ( (retval= DiceEntropyUsed(oldbetTx,oldbettxid,oldentropyvout,entropyused,bettxid,betTx,entropyvout)) != 0 ) { if ( retval < 0 ) { @@ -1557,7 +1563,7 @@ std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t *resultp, } //fprintf(stderr,"make tx.%c\n",funcid); if ( funcid == 'L' || funcid == 'W' ) // dealernode only - hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash); + hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash,mtx.vin[0].prevout.n); *resultp = 1; //char str[65],str2[65]; //fprintf(stderr,"iswin.%d house entropy %s vs bettor %s\n",iswin,uint256_str(str,hentropyproof),uint256_str(str2,bettorentropy)); @@ -1577,7 +1583,7 @@ std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t *resultp, double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettxid) { - CScript fundingPubKey,scriptPubKey; CTransaction spenttx,betTx,entropyTx; uint256 hentropyproof,entropyused,hash,proof,txid,hashBlock,spenttxid,bettorentropy; CPubKey mypk,dicepk,fundingpk; struct CCcontract_info *cp,C; int32_t i,flag,win,loss,duplicate=0,result,iswin,vout,n=0; int64_t minbet,maxbet,maxodds,timeoutblocks,sum=0; uint64_t sbits,refsbits; char coinaddr[64]; std::string res; uint8_t funcid; + CScript fundingPubKey,scriptPubKey; CTransaction spenttx,betTx,entropyTx; uint256 hentropyproof,entropyused,hash,proof,txid,hashBlock,spenttxid,bettorentropy; CPubKey mypk,dicepk,fundingpk; struct CCcontract_info *cp,C; int32_t i,entropyvout,flag,win,loss,duplicate=0,result,iswin,vout,n=0; int64_t minbet,maxbet,maxodds,timeoutblocks,sum=0; uint64_t sbits,refsbits; char coinaddr[64]; std::string res; uint8_t funcid; if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,refsbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { CCerror = "Diceinit error in status"; @@ -1608,24 +1614,24 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx if ( scriptPubKey == fundingPubKey ) { bettorentropy = DiceGetEntropy(betTx,'B'); - if ( (iswin= DiceIsWinner(hentropyproof,txid,betTx,entropyTx,bettorentropy,sbits,minbet,maxbet,maxodds,timeoutblocks,fundingtxid)) != 0 ) + if ( (iswin= DiceIsWinner(hentropyproof,entropyvout,txid,betTx,entropyTx,bettorentropy,sbits,minbet,maxbet,maxodds,timeoutblocks,fundingtxid)) != 0 ) { if ( iswin > 0 ) win++; else if ( iswin < 0 ) loss++; n++; - DiceQueue(iswin,sbits,fundingtxid,txid,betTx); + DiceQueue(iswin,sbits,fundingtxid,txid,betTx,entropyvout); } //else flag = 1; } if ( flag != 0 || scriptPubKey != fundingPubKey ) { if ( flag != 0 ) fprintf(stderr,"illegal bettxid %d: iswin.%d W.%d L.%d %s/v%d (%c %.8f) %.8f\n",n,iswin,win,loss,txid.GetHex().c_str(),vout,funcid,(double)it->second.satoshis/COIN,(double)sum/COIN); - res = DiceBetFinish(funcid,entropyused,&result,txfee,planstr,fundingtxid,txid,scriptPubKey == fundingPubKey,zeroid,-1); + res = DiceBetFinish(funcid,entropyused,entropyvout,&result,txfee,planstr,fundingtxid,txid,scriptPubKey == fundingPubKey,zeroid,-1); if ( result > 0 ) { - mySenddicetransaction(res,entropyused,txid,betTx,funcid,0); + mySenddicetransaction(res,entropyused,entropyvout,txid,betTx,funcid,0); n++; } } @@ -1676,11 +1682,11 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx return(-1.); } else if ( scriptPubKey == fundingPubKey ) - res = DiceBetFinish(funcid,entropyused,&result,txfee,planstr,fundingtxid,bettxid,1,zeroid,-1); - else res = DiceBetFinish(funcid,entropyused,&result,txfee,planstr,fundingtxid,bettxid,0,zeroid,-1); + res = DiceBetFinish(funcid,entropyused,entropyvout,&result,txfee,planstr,fundingtxid,bettxid,1,zeroid,-1); + else res = DiceBetFinish(funcid,entropyused,entropyvout,&result,txfee,planstr,fundingtxid,bettxid,0,zeroid,-1); if ( result > 0 ) { - mySenddicetransaction(res,entropyused,bettxid,betTx,funcid,0); + mySenddicetransaction(res,entropyused,entropyvout,bettxid,betTx,funcid,0); sleep(1); if ( (vout= myIsutxo_spent(spenttxid,bettxid,1)) >= 0 ) { From f82a0196dbbdaa209993fd79b51590bf68d39b3b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 03:02:53 -1100 Subject: [PATCH 035/135] Fix --- src/cc/dice.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 05f448550..7f1f728eb 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -227,7 +227,7 @@ bool mySenddicetransaction(std::string res,uint256 entropyused,int32_t entropyvo if ( ptr != 0 ) ptr->revealed = (uint32_t)time(NULL); pthread_mutex_lock(&DICEREVEALED_MUTEX); - _dicerevealed_add(entropyused,bettxid,betTx); + _dicerevealed_add(entropyused,bettxid,betTx,entropyvout); pthread_mutex_unlock(&DICEREVEALED_MUTEX); fprintf(stderr,"added.%c to mempool.[%d] and broadcast entropyused.%s bettxid.%s -> %s\n",funcid,i,entropyused.GetHex().c_str(),bettxid.GetHex().c_str(),tx.GetHash().GetHex().c_str()); } else fprintf(stderr,"rebroadcast.%c to mempool.[%d] and broadcast entropyused.%s bettxid.%s -> %s\n",funcid,i,entropyused.GetHex().c_str(),bettxid.GetHex().c_str(),tx.GetHash().GetHex().c_str()); @@ -411,7 +411,11 @@ void *dicefinish(void *_ptr) { unstringbits(name,ptr->sbits); result = 0; - res = DiceBetFinish(ptr->funcid,ptr->entropyused,ptr->entropyvout,&result,0,name,ptr->fundingtxid,ptr->bettxid,ptr->iswin,utxos[m].txid,utxos[m].vout); + res = DiceBetFinish(ptr->funcid,entropyused,entropyvout,&result,0,name,ptr->fundingtxid,ptr->bettxid,ptr->iswin,utxos[m].txid,utxos[m].vout); + if ( entropyused != ptr->entropyused || entropyvout != ptr->entropyvout ) + { + fprintf(stderr,"WARNING entropy %s != %s || %d != %d\n",entropyused.GetHex().c_str(),ptr->entropyused.GetHex().c_str(),entropyvout,ptr->entropyvout); + } if ( result > 0 ) { ptr->rawtx = res; @@ -1417,7 +1421,7 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t &entropyvout,int32_t *resultp,uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettxid,int32_t winlosetimeout,uint256 vin0txid,int32_t vin0vout) { - CMutableTransaction mtx; CScript scriptPubKey,fundingPubKey; CTransaction oldbetTx,betTx,entropyTx; uint256 hentropyproof,entropytxid,hashBlock,bettorentropy,entropy,hentropy,oldbettxid; CPubKey mypk,dicepk,fundingpk; struct CCcontract_info *cp,C; int64_t inputs=0,CCchange=0,odds,fundsneeded,minbet,maxbet,maxodds,timeoutblocks; int32_t oldentropyvout,entropyvout,retval,iswin=0; uint64_t entropyval,sbits; + CMutableTransaction mtx; CScript scriptPubKey,fundingPubKey; CTransaction oldbetTx,betTx,entropyTx; uint256 hentropyproof,entropytxid,hashBlock,bettorentropy,entropy,hentropy,oldbettxid; CPubKey mypk,dicepk,fundingpk; struct CCcontract_info *cp,C; int64_t inputs=0,CCchange=0,odds,fundsneeded,minbet,maxbet,maxodds,timeoutblocks; int32_t oldentropyvout,retval,iswin=0; uint64_t entropyval,sbits; entropyused = zeroid; *resultp = 0; funcid = 0; From 1fdbde84b8151d93aedd57d35680f230daec68d3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 03:03:56 -1100 Subject: [PATCH 036/135] Fix --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 7f1f728eb..535621b6d 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -311,7 +311,7 @@ void dicefinish_delete(struct dicefinish_info *ptr) void *dicefinish(void *_ptr) { - std::vector mypk; struct CCcontract_info *cp,C; char name[32],coinaddr[64],CCaddr[64]; std::string res; int32_t newht,newblock,numblocks,lastheight=0,vin0_needed,n,m,num,iter,result; struct dicefinish_info *ptr,*tmp; uint32_t now; struct dicefinish_utxo *utxos; uint256 hashBlock; CTransaction betTx,finishTx; + std::vector mypk; struct CCcontract_info *cp,C; char name[32],coinaddr[64],CCaddr[64]; std::string res; int32_t newht,newblock,entropyvout,numblocks,lastheight=0,vin0_needed,n,m,num,iter,result; struct dicefinish_info *ptr,*tmp; uint32_t now; struct dicefinish_utxo *utxos; uint256 hashBlock,entropyused; CTransaction betTx,finishTx; mypk = Mypubkey(); pubkey2addr(coinaddr,mypk.data()); cp = CCinit(&C,EVAL_DICE); From 6390d04064ac6aabf9027ccc925aab059b64bda9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 03:07:16 -1100 Subject: [PATCH 037/135] Test --- src/cc/CCdice.h | 2 +- src/wallet/rpcwallet.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/CCdice.h b/src/cc/CCdice.h index bd8d1d5fa..8c67d86fe 100644 --- a/src/cc/CCdice.h +++ b/src/cc/CCdice.h @@ -24,7 +24,7 @@ bool DiceValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx); std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet,int32_t odds); -std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t *resultp,uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettxid,int32_t winlosetimeout,uint256 vin0txid,int32_t vin0vout); +std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t &entropyvout,int32_t *resultp,uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettxid,int32_t winlosetimeout,uint256 vin0txid,int32_t vin0vout); double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettxid); std::string DiceCreateFunding(uint64_t txfee,char *planstr,int64_t funds,int64_t minbet,int64_t maxbet,int64_t maxodds,int64_t timeoutblocks); std::string DiceAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t amount); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 5f5cb5b28..394ff4a35 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -6182,7 +6182,7 @@ UniValue dicebet(const UniValue& params, bool fHelp) UniValue dicefinish(const UniValue& params, bool fHelp) { - UniValue result(UniValue::VOBJ); uint8_t funcid; char *name; uint256 entropyused,fundingtxid,bettxid; std::string hex; int32_t r; + UniValue result(UniValue::VOBJ); uint8_t funcid; char *name; uint256 entropyused,fundingtxid,bettxid; std::string hex; int32_t r,entropyvout; if ( fHelp || params.size() != 3 ) throw runtime_error("dicefinish name fundingtxid bettxid\n"); if ( ensure_CCrequirements() < 0 ) @@ -6196,7 +6196,7 @@ UniValue dicefinish(const UniValue& params, bool fHelp) } fundingtxid = Parseuint256((char *)params[1].get_str().c_str()); bettxid = Parseuint256((char *)params[2].get_str().c_str()); - hex = DiceBetFinish(funcid,entropyused,&r,0,name,fundingtxid,bettxid,1,zeroid,-1); + hex = DiceBetFinish(funcid,entropyused,entropyvout,&r,0,name,fundingtxid,bettxid,1,zeroid,-1); if ( CCerror != "" ) { ERR_RESULT(CCerror); From 9841d2984e853a06ccc736cfa9d91e5b8405bbe6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 03:10:10 -1100 Subject: [PATCH 038/135] Test --- src/cc/CCinclude.h | 2 +- src/cc/channels.cpp | 6 +++--- src/cc/lotto.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index aa5e731b3..41f5ccacd 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -125,7 +125,7 @@ CPubKey GetUnspendable(struct CCcontract_info *cp,uint8_t *unspendablepriv); // CCutils CPubKey buf2pk(uint8_t *buf33); void endiancpy(uint8_t *dest,uint8_t *src,int32_t len); -uint256 DiceHashEntropy(uint256 &entropy,uint256 _txidpriv); +uint256 DiceHashEntropy(uint256 &entropy,uint256 _txidpriv,int32_t entropyvout); CTxOut MakeCC1vout(uint8_t evalcode,CAmount nValue,CPubKey pk); CTxOut MakeCC1of2vout(uint8_t evalcode,CAmount nValue,CPubKey pk,CPubKey pk2); CC *MakeCCcond1(uint8_t evalcode,CPubKey pk); diff --git a/src/cc/channels.cpp b/src/cc/channels.cpp index 672e426a8..e5b77feb2 100644 --- a/src/cc/channels.cpp +++ b/src/cc/channels.cpp @@ -446,7 +446,7 @@ std::string ChannelOpen(uint64_t txfee,CPubKey destpub,int32_t numpayments,int64 funds = numpayments * payment; if ( AddNormalinputs(mtx,mypk,funds+3*txfee,64) > 0 ) { - hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash); + hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash,mtx.vin[0].prevout.n); endiancpy(hash,(uint8_t *)&hentropy,32); for (i=0; i 0 && DecodeChannelsOpRet(prevTx.vout[numvouts-1].scriptPubKey, txid, srcpub, destpub, param1, param2, param3) != 0) { - hentropy = DiceHashEntropy(entropy, channelOpenTx.vin[0].prevout.hash); + hentropy = DiceHashEntropy(entropy, channelOpenTx.vin[0].prevout.hash, channelOpenTx.vin[0].prevout.n); endiancpy(hash, (uint8_t * ) & hentropy, 32); for (i = 0; i < param1; i++) { diff --git a/src/cc/lotto.cpp b/src/cc/lotto.cpp index d6d881603..6361b9291 100644 --- a/src/cc/lotto.cpp +++ b/src/cc/lotto.cpp @@ -292,7 +292,7 @@ std::string LottoCreate(uint64_t txfee,char *planstr,int64_t funding,int32_t tic sbits = stringbits(planstr); if ( AddNormalinputs(mtx,mypk,funding+txfee,60) > 0 ) { - hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash); + hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash,mtx.vin[0].prevout.n); mtx.vout.push_back(MakeCC1vout(EVAL_LOTTO,funding,lottopk)); return(FinalizeCCTx(0,cp,mtx,mypk,txfee,CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)EVAL_LOTTO << (uint8_t)'F' << sbits << ticketsize << odds << firstheight << period << hentropy))); } From ca9e12808036f20ca05af06bf59adef2a3bc6b0d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 03:23:16 -1100 Subject: [PATCH 039/135] Test --- src/cc/dice.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 535621b6d..034977a1d 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -412,6 +412,11 @@ void *dicefinish(void *_ptr) unstringbits(name,ptr->sbits); result = 0; res = DiceBetFinish(ptr->funcid,entropyused,entropyvout,&result,0,name,ptr->fundingtxid,ptr->bettxid,ptr->iswin,utxos[m].txid,utxos[m].vout); + if ( ptr->entropyused == zeroid ) + { + ptr->entropyused = entropyused; + ptr->entropyvout = entropyvout; + } if ( entropyused != ptr->entropyused || entropyvout != ptr->entropyvout ) { fprintf(stderr,"WARNING entropy %s != %s || %d != %d\n",entropyused.GetHex().c_str(),ptr->entropyused.GetHex().c_str(),entropyvout,ptr->entropyvout); From 3fb115a5a06dbf7258eb9351daa8599d9a9866e6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 03:32:29 -1100 Subject: [PATCH 040/135] Test --- src/cc/dice.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 034977a1d..98a507ea0 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -102,7 +102,7 @@ What is needed is for the dealer node to track the entropy tx that was already b extern int32_t KOMODO_INSYNC; -static uint256 bettxids[MAX_ENTROPYUSED],entropytxids[MAX_ENTROPYUSED][2]; // change to hashtable +static uint256 bettxids[MAX_ENTROPYUSED],entropyused[MAX_ENTROPYUSED][2]; // change to hashtable static CTransaction betTxs[MAX_ENTROPYUSED]; static int32_t entropyvouts[MAX_ENTROPYUSED]; @@ -161,15 +161,18 @@ int32_t _dicerevealed_find(uint256 &oldbettxid,CTransaction &oldbetTx,int32_t &o int32_t i; for (i=0; i Date: Sat, 10 Nov 2018 03:34:37 -1100 Subject: [PATCH 041/135] Test --- src/cc/dice.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 98a507ea0..818efbfab 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -102,7 +102,7 @@ What is needed is for the dealer node to track the entropy tx that was already b extern int32_t KOMODO_INSYNC; -static uint256 bettxids[MAX_ENTROPYUSED],entropyused[MAX_ENTROPYUSED][2]; // change to hashtable +static uint256 bettxids[MAX_ENTROPYUSED],Entropyused[MAX_ENTROPYUSED][2]; // change to hashtable static CTransaction betTxs[MAX_ENTROPYUSED]; static int32_t entropyvouts[MAX_ENTROPYUSED]; @@ -161,14 +161,14 @@ int32_t _dicerevealed_find(uint256 &oldbettxid,CTransaction &oldbetTx,int32_t &o int32_t i; for (i=0; i Date: Sat, 10 Nov 2018 03:40:44 -1100 Subject: [PATCH 042/135] Test --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 818efbfab..fdd3a9bd4 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -767,7 +767,7 @@ int32_t DiceIsWinner(uint256 &entropy,int32_t &entropyvout,uint256 txid,CTransac { hentropy2 = DiceHashEntropy(entropy,vinTx.vin[0].prevout.hash,vinTx.vin[0].prevout.n); entropyvout = vinTx.vin[0].prevout.n; - fprintf(stderr,"bettxid %s -> vin0 %s/v%d -> %s\n",txid.GetHex().c_str(),vinTx.vin[0].prevout.hash.GetHex().c_str(),entropyvout,entropy.GetHex().c_str()); + fprintf(stderr,"%d bettxid %s -> vin0 %s/v%d -> %s\n",KOMODO_CONNECTING,txid.GetHex().c_str(),vinTx.vin[0].prevout.hash.GetHex().c_str(),entropyvout,entropy.GetHex().c_str()); if ( hentropy == hentropy2 ) { winnings = DiceCalc(tx.vout[1].nValue,tx.vout[2].nValue,minbet,maxbet,maxodds,timeoutblocks,entropy,bettorentropy); From 70b30de84b3e11cdf6dd25e75d4f49ebfdd769ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 03:44:29 -1100 Subject: [PATCH 043/135] Test --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index fdd3a9bd4..f5b342cec 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -767,7 +767,7 @@ int32_t DiceIsWinner(uint256 &entropy,int32_t &entropyvout,uint256 txid,CTransac { hentropy2 = DiceHashEntropy(entropy,vinTx.vin[0].prevout.hash,vinTx.vin[0].prevout.n); entropyvout = vinTx.vin[0].prevout.n; - fprintf(stderr,"%d bettxid %s -> vin0 %s/v%d -> %s\n",KOMODO_CONNECTING,txid.GetHex().c_str(),vinTx.vin[0].prevout.hash.GetHex().c_str(),entropyvout,entropy.GetHex().c_str()); + fprintf(stderr,"%d bettxid %s -> vin0 %s/v%d -> %s\n",KOMODO_CONNECTING & ((1<<30) - 1),txid.GetHex().c_str(),vinTx.vin[0].prevout.hash.GetHex().c_str(),entropyvout,entropy.GetHex().c_str()); if ( hentropy == hentropy2 ) { winnings = DiceCalc(tx.vout[1].nValue,tx.vout[2].nValue,minbet,maxbet,maxodds,timeoutblocks,entropy,bettorentropy); From dcbcc65cba37d817a3f9f122db8f55d96cf57401 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 03:45:05 -1100 Subject: [PATCH 044/135] +print --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index f5b342cec..d2c3c85dd 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -767,7 +767,7 @@ int32_t DiceIsWinner(uint256 &entropy,int32_t &entropyvout,uint256 txid,CTransac { hentropy2 = DiceHashEntropy(entropy,vinTx.vin[0].prevout.hash,vinTx.vin[0].prevout.n); entropyvout = vinTx.vin[0].prevout.n; - fprintf(stderr,"%d bettxid %s -> vin0 %s/v%d -> %s\n",KOMODO_CONNECTING & ((1<<30) - 1),txid.GetHex().c_str(),vinTx.vin[0].prevout.hash.GetHex().c_str(),entropyvout,entropy.GetHex().c_str()); + fprintf(stderr,"%d mem.%d bettxid %s -> vin0 %s/v%d -> %s\n",KOMODO_CONNECTING & ((1<<30) - 1),(KOMODO_CONNECTING & (1<<30)) != 0,txid.GetHex().c_str(),vinTx.vin[0].prevout.hash.GetHex().c_str(),entropyvout,entropy.GetHex().c_str()); if ( hentropy == hentropy2 ) { winnings = DiceCalc(tx.vout[1].nValue,tx.vout[2].nValue,minbet,maxbet,maxodds,timeoutblocks,entropy,bettorentropy); From 6c357b930fcda111160b92c61ae0efe46b48f081 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 03:49:20 -1100 Subject: [PATCH 045/135] -print --- src/cc/dice.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index d2c3c85dd..9f5d83979 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1162,7 +1162,9 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit fprintf(stderr," (%c) tx vin.%d fundingPubKey mismatch %s\n",funcid,tx.vin[0].prevout.n,uint256_str(str,tx.vin[0].prevout.hash)); } } - } else fprintf(stderr,"%s %c refsbits.%llx sbits.%llx nValue %.8f\n",uint256_str(str,txid),funcid,(long long)refsbits,(long long)sbits,(double)nValue/COIN); + } + else if ( funcid != 'B' ) + fprintf(stderr,"%s %c refsbits.%llx sbits.%llx nValue %.8f\n",uint256_str(str,txid),funcid,(long long)refsbits,(long long)sbits,(double)nValue/COIN); } //else fprintf(stderr,"else case funcid (%c) %d %s vs %s\n",funcid,funcid,uint256_str(str,reffundingtxid),uint256_str(str2,fundingtxid)); } //else fprintf(stderr,"funcid.%d %c skipped %.8f\n",funcid,funcid,(double)tx.vout[vout].nValue/COIN); } i = i + 1; From 37229257354bfdc9a591ea77acb819f5dba7680b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 04:33:05 -1100 Subject: [PATCH 046/135] +print --- src/komodo_utils.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 8fb50c23e..9be15277d 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1634,6 +1634,7 @@ void komodo_args(char *argv0) MAX_MONEY += (MAX_MONEY * ASSETCHAINS_COMMISSION) / SATOSHIDEN; if ( ASSETCHAINS_CC >= KOMODO_FIRSTFUNGIBLEID && MAX_MONEY < 1000000LL*SATOSHIDEN ) MAX_MONEY = 1000000LL*SATOSHIDEN; + fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN); //printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN); ASSETCHAINS_P2PPORT = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen); while ( (dirname= (char *)GetDataDir(false).string().c_str()) == 0 || dirname[0] == 0 ) From e1f20c0b202be1a9008ca3ca796552a5ac85fa99 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 04:35:46 -1100 Subject: [PATCH 047/135] Cap MAX_MONEY --- src/komodo_utils.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 9be15277d..e669e1368 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1634,6 +1634,8 @@ void komodo_args(char *argv0) MAX_MONEY += (MAX_MONEY * ASSETCHAINS_COMMISSION) / SATOSHIDEN; if ( ASSETCHAINS_CC >= KOMODO_FIRSTFUNGIBLEID && MAX_MONEY < 1000000LL*SATOSHIDEN ) MAX_MONEY = 1000000LL*SATOSHIDEN; + if ( MAX_MONEY < 0 || MAX_MONEY > 1000000000LL*SATOSHIDEN ) + MAX_MONEY = 1000000000LL*SATOSHIDEN; fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN); //printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN); ASSETCHAINS_P2PPORT = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen); From fa7e40ac2872e048fd7fb0648b4e45e09d7af89d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 04:36:03 -1100 Subject: [PATCH 048/135] <= --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index e669e1368..2b1846850 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1634,7 +1634,7 @@ void komodo_args(char *argv0) MAX_MONEY += (MAX_MONEY * ASSETCHAINS_COMMISSION) / SATOSHIDEN; if ( ASSETCHAINS_CC >= KOMODO_FIRSTFUNGIBLEID && MAX_MONEY < 1000000LL*SATOSHIDEN ) MAX_MONEY = 1000000LL*SATOSHIDEN; - if ( MAX_MONEY < 0 || MAX_MONEY > 1000000000LL*SATOSHIDEN ) + if ( MAX_MONEY <= 0 || MAX_MONEY > 1000000000LL*SATOSHIDEN ) MAX_MONEY = 1000000000LL*SATOSHIDEN; fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN); //printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN); From d19cb2c8a74a512e1713010c6ef3c1cb361b3f12 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 04:54:17 -1100 Subject: [PATCH 049/135] Fix founders reward --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index ae16d513c..67b583f96 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1114,7 +1114,7 @@ uint64_t komodo_commission(const CBlock *pblock) { n = pblock->vtx[0].vout.size(); for (j=0; jvtx[i].vout[j].nValue; + total += pblock->vtx[0].vout[j].nValue; } else { From f69b32b9645ae7abb034b39081d45b0a1d8237a9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 05:09:29 -1100 Subject: [PATCH 050/135] Test --- src/cc/dice.cpp | 25 ++++++++++++++++++------- src/komodo_bitcoind.h | 4 ++-- src/miner.cpp | 2 +- 3 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 9f5d83979..e165127df 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -528,11 +528,13 @@ CPubKey DiceFundingPk(CScript scriptPubKey) return(pk); } -uint256 DiceHashEntropy(uint256 &entropy,uint256 _txidpriv,int32_t vout) +uint256 DiceHashEntropy(uint256 &entropy,uint256 _txidpriv,int32_t vout,int32_t usevout) { int32_t i; uint8_t _entropy[32],_hentropy[32]; bits256 tmp256,txidpub,txidpriv,mypriv,mypub,ssecret,ssecret2; uint256 hentropy; memset(&hentropy,0,32); endiancpy(txidpriv.bytes,(uint8_t *)&_txidpriv,32); + if ( usevout != 0 ) + txidpriv.ints[1] = vout; txidpriv.bytes[0] &= 0xf8, txidpriv.bytes[31] &= 0x7f, txidpriv.bytes[31] |= 0x40; txidpub = curve25519(txidpriv,curve25519_basepoint9()); @@ -765,9 +767,14 @@ int32_t DiceIsWinner(uint256 &entropy,int32_t &entropyvout,uint256 txid,CTransac { if ( ((funcid= DecodeDiceOpRet(txid,vinTx.vout[vinTx.vout.size()-1].scriptPubKey,vinsbits,vinfundingtxid,hentropy,vinproof)) == 'E' || funcid == 'W' || funcid == 'L') && sbits == vinsbits && fundingtxid == vinfundingtxid ) { - hentropy2 = DiceHashEntropy(entropy,vinTx.vin[0].prevout.hash,vinTx.vin[0].prevout.n); + hentropy2 = DiceHashEntropy(entropy,vinTx.vin[0].prevout.hash,vinTx.vin[0].prevout.n,0); entropyvout = vinTx.vin[0].prevout.n; - fprintf(stderr,"%d mem.%d bettxid %s -> vin0 %s/v%d -> %s\n",KOMODO_CONNECTING & ((1<<30) - 1),(KOMODO_CONNECTING & (1<<30)) != 0,txid.GetHex().c_str(),vinTx.vin[0].prevout.hash.GetHex().c_str(),entropyvout,entropy.GetHex().c_str()); + fprintf(stderr,"bettxid %s -> vin0 %s/v%d -> %s\n",txid.GetHex().c_str(),vinTx.vin[0].prevout.hash.GetHex().c_str(),entropyvout,entropy.GetHex().c_str()); + if ( hentropy != hentropy2 ) + { + hentropy2 = DiceHashEntropy(entropy,vinTx.vin[0].prevout.hash,vinTx.vin[0].prevout.n,1); + fprintf(stderr,"alt bettxid %s -> vin0 %s/v%d -> %s\n",txid.GetHex().c_str(),vinTx.vin[0].prevout.hash.GetHex().c_str(),entropyvout,entropy.GetHex().c_str()); + } if ( hentropy == hentropy2 ) { winnings = DiceCalc(tx.vout[1].nValue,tx.vout[2].nValue,minbet,maxbet,maxodds,timeoutblocks,entropy,bettorentropy); @@ -783,7 +790,11 @@ int32_t DiceIsWinner(uint256 &entropy,int32_t &entropyvout,uint256 txid,CTransac // queue 'W' winning tx return(1); } - } else fprintf(stderr,"hentropy != hentropy2\n"); + } + else + { + fprintf(stderr,"both hentropy != hentropy2\n"); + } } else fprintf(stderr,"funcid.%c sbits %llx vs %llx cmp.%d\n",funcid,(long long)sbits,(long long)vinsbits,fundingtxid == vinfundingtxid); } //else fprintf(stderr,"notmine.%d or not CC.%d\n",DiceIsmine(vinTx.vout[1].scriptPubKey) != 0,vinTx.vout[0].scriptPubKey.IsPayToCryptoCondition() != 0); return(0); @@ -1356,7 +1367,7 @@ std::string DiceAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,int6 { if ( AddNormalinputs(mtx,mypk,amount+2*txfee,1) > 0 ) { - hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash,mtx.vin[0].prevout.n); + hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash,mtx.vin[0].prevout.n,1); mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,dicepk)); mtx.vout.push_back(CTxOut(txfee,fundingPubKey)); return(FinalizeCCTx(0,cp,mtx,mypk,txfee,EncodeDiceOpRet('E',sbits,fundingtxid,hentropy,zeroid))); @@ -1415,7 +1426,7 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet mtx.vin.push_back(CTxIn(entropytxid,0,CScript())); if ( AddNormalinputs(mtx,mypk,bet+2*txfee+odds,60) > 0 ) { - hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash,mtx.vin[0].prevout.n); + hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash,mtx.vin[0].prevout.n,1); mtx.vout.push_back(MakeCC1vout(cp->evalcode,entropyval,dicepk)); mtx.vout.push_back(MakeCC1vout(cp->evalcode,bet,dicepk)); mtx.vout.push_back(CTxOut(txfee+odds,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); @@ -1577,7 +1588,7 @@ std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t &entropyv } //fprintf(stderr,"make tx.%c\n",funcid); if ( funcid == 'L' || funcid == 'W' ) // dealernode only - hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash,mtx.vin[0].prevout.n); + hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash,mtx.vin[0].prevout.n,1); *resultp = 1; //char str[65],str2[65]; //fprintf(stderr,"iswin.%d house entropy %s vs bettor %s\n",iswin,uint256_str(str,hentropyproof),uint256_str(str2,bettorentropy)); diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 67b583f96..eb5d02e76 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1476,9 +1476,9 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) if ( ASSETCHAINS_COMMISSION != 0 ) { checktoshis = komodo_commission(pblock); - if ( checktoshis > 10000 && pblock->vtx[0].vout.size() != 2 ) + /*if ( checktoshis > 10000 && pblock->vtx[0].vout.size() != 2 ) return(-1); - else if ( checktoshis != 0 ) + else*/ if ( checktoshis != 0 ) { script = (uint8_t *)pblock->vtx[0].vout[1].scriptPubKey.data(); if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) diff --git a/src/miner.cpp b/src/miner.cpp index 3b245b286..71a22b7d8 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -749,7 +749,7 @@ void static BitcoinMiner() unsigned int n = chainparams.EquihashN(); unsigned int k = chainparams.EquihashK(); - uint8_t *script; uint64_t total,checktoshis; int32_t i,j,gpucount=KOMODO_MAXGPUCOUNT,notaryid = -1; + uint8_t *script; uint64_t total; int32_t i,j,gpucount=KOMODO_MAXGPUCOUNT,notaryid = -1; while ( (ASSETCHAIN_INIT == 0 || KOMODO_INITDONE == 0) ) { sleep(1); From 02a1c3a7dd3aefa8e43b25be07428ebed6097fd7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 05:10:46 -1100 Subject: [PATCH 051/135] Fix --- src/cc/dice.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index e165127df..491c37118 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -533,8 +533,8 @@ uint256 DiceHashEntropy(uint256 &entropy,uint256 _txidpriv,int32_t vout,int32_t int32_t i; uint8_t _entropy[32],_hentropy[32]; bits256 tmp256,txidpub,txidpriv,mypriv,mypub,ssecret,ssecret2; uint256 hentropy; memset(&hentropy,0,32); endiancpy(txidpriv.bytes,(uint8_t *)&_txidpriv,32); - if ( usevout != 0 ) - txidpriv.ints[1] = vout; + //if ( usevout != 0 ) + // txidpriv.ints[1] = vout; txidpriv.bytes[0] &= 0xf8, txidpriv.bytes[31] &= 0x7f, txidpriv.bytes[31] |= 0x40; txidpub = curve25519(txidpriv,curve25519_basepoint9()); From bd19a3867b58b65caf3078dcc7378d104722c8cb Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 05:14:50 -1100 Subject: [PATCH 052/135] Usevout --- src/cc/CCinclude.h | 2 +- src/cc/channels.cpp | 6 +++--- src/cc/dice.cpp | 4 ++-- src/cc/lotto.cpp | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 41f5ccacd..83642f020 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -125,7 +125,7 @@ CPubKey GetUnspendable(struct CCcontract_info *cp,uint8_t *unspendablepriv); // CCutils CPubKey buf2pk(uint8_t *buf33); void endiancpy(uint8_t *dest,uint8_t *src,int32_t len); -uint256 DiceHashEntropy(uint256 &entropy,uint256 _txidpriv,int32_t entropyvout); +uint256 DiceHashEntropy(uint256 &entropy,uint256 _txidpriv,int32_t entropyvout,int32_t usevout); CTxOut MakeCC1vout(uint8_t evalcode,CAmount nValue,CPubKey pk); CTxOut MakeCC1of2vout(uint8_t evalcode,CAmount nValue,CPubKey pk,CPubKey pk2); CC *MakeCCcond1(uint8_t evalcode,CPubKey pk); diff --git a/src/cc/channels.cpp b/src/cc/channels.cpp index e5b77feb2..a03a602d5 100644 --- a/src/cc/channels.cpp +++ b/src/cc/channels.cpp @@ -446,7 +446,7 @@ std::string ChannelOpen(uint64_t txfee,CPubKey destpub,int32_t numpayments,int64 funds = numpayments * payment; if ( AddNormalinputs(mtx,mypk,funds+3*txfee,64) > 0 ) { - hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash,mtx.vin[0].prevout.n); + hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash,mtx.vin[0].prevout.n,1); endiancpy(hash,(uint8_t *)&hentropy,32); for (i=0; i 0 && DecodeChannelsOpRet(prevTx.vout[numvouts-1].scriptPubKey, txid, srcpub, destpub, param1, param2, param3) != 0) { - hentropy = DiceHashEntropy(entropy, channelOpenTx.vin[0].prevout.hash, channelOpenTx.vin[0].prevout.n); + hentropy = DiceHashEntropy(entropy, channelOpenTx.vin[0].prevout.hash, channelOpenTx.vin[0].prevout.n,1); endiancpy(hash, (uint8_t * ) & hentropy, 32); for (i = 0; i < param1; i++) { diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 491c37118..017353dcf 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -533,8 +533,8 @@ uint256 DiceHashEntropy(uint256 &entropy,uint256 _txidpriv,int32_t vout,int32_t int32_t i; uint8_t _entropy[32],_hentropy[32]; bits256 tmp256,txidpub,txidpriv,mypriv,mypub,ssecret,ssecret2; uint256 hentropy; memset(&hentropy,0,32); endiancpy(txidpriv.bytes,(uint8_t *)&_txidpriv,32); - //if ( usevout != 0 ) - // txidpriv.ints[1] = vout; + if ( usevout != 0 ) + txidpriv.uints[1] ^= vout; txidpriv.bytes[0] &= 0xf8, txidpriv.bytes[31] &= 0x7f, txidpriv.bytes[31] |= 0x40; txidpub = curve25519(txidpriv,curve25519_basepoint9()); diff --git a/src/cc/lotto.cpp b/src/cc/lotto.cpp index 6361b9291..652ea9d0d 100644 --- a/src/cc/lotto.cpp +++ b/src/cc/lotto.cpp @@ -292,7 +292,7 @@ std::string LottoCreate(uint64_t txfee,char *planstr,int64_t funding,int32_t tic sbits = stringbits(planstr); if ( AddNormalinputs(mtx,mypk,funding+txfee,60) > 0 ) { - hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash,mtx.vin[0].prevout.n); + hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash,mtx.vin[0].prevout.n,1); mtx.vout.push_back(MakeCC1vout(EVAL_LOTTO,funding,lottopk)); return(FinalizeCCTx(0,cp,mtx,mypk,txfee,CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)EVAL_LOTTO << (uint8_t)'F' << sbits << ticketsize << odds << firstheight << period << hentropy))); } From df5b020b34b392c49a5589ffd8b71091875d2983 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 05:28:52 -1100 Subject: [PATCH 053/135] Endian fix --- src/cc/dice.cpp | 5 ++++- src/komodo_utils.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 017353dcf..604433e0b 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -534,7 +534,10 @@ uint256 DiceHashEntropy(uint256 &entropy,uint256 _txidpriv,int32_t vout,int32_t memset(&hentropy,0,32); endiancpy(txidpriv.bytes,(uint8_t *)&_txidpriv,32); if ( usevout != 0 ) - txidpriv.uints[1] ^= vout; + { + txidpriv.bytes[1] ^= (vout & 0xff); + txidpriv.bytes[2] ^= ((vout>>8) & 0xff); + } txidpriv.bytes[0] &= 0xf8, txidpriv.bytes[31] &= 0x7f, txidpriv.bytes[31] |= 0x40; txidpub = curve25519(txidpriv,curve25519_basepoint9()); diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 2b1846850..09c5622af 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1636,7 +1636,7 @@ void komodo_args(char *argv0) MAX_MONEY = 1000000LL*SATOSHIDEN; if ( MAX_MONEY <= 0 || MAX_MONEY > 1000000000LL*SATOSHIDEN ) MAX_MONEY = 1000000000LL*SATOSHIDEN; - fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN); + //fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN); //printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN); ASSETCHAINS_P2PPORT = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen); while ( (dirname= (char *)GetDataDir(false).string().c_str()) == 0 || dirname[0] == 0 ) From b045472360d66cde0d44aa83f873b6c78fa36ced Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 05:38:52 -1100 Subject: [PATCH 054/135] +print --- src/cc/dice.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 604433e0b..5eb3605ae 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -391,7 +391,7 @@ void *dicefinish(void *_ptr) 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\n",iter,vin0_needed,n); + fprintf(stderr,"iter.%d vin0_needed.%d got %d\n",iter,vin0_needed,n); m = 0; DL_FOREACH_SAFE(DICEFINISH_LIST,ptr,tmp) { @@ -406,7 +406,7 @@ void *dicefinish(void *_ptr) if ( ptr->txid != zeroid ) { CCduration(numblocks,ptr->txid); - //fprintf(stderr,"numblocks %s %d\n",ptr->txid.GetHex().c_str(),numblocks); + fprintf(stderr,"numblocks %s %d\n",ptr->txid.GetHex().c_str(),numblocks); if ( numblocks > 0 ) continue; } @@ -441,7 +441,7 @@ void *dicefinish(void *_ptr) } else { - //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)); + 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)); } } } @@ -772,7 +772,7 @@ int32_t DiceIsWinner(uint256 &entropy,int32_t &entropyvout,uint256 txid,CTransac { hentropy2 = DiceHashEntropy(entropy,vinTx.vin[0].prevout.hash,vinTx.vin[0].prevout.n,0); entropyvout = vinTx.vin[0].prevout.n; - fprintf(stderr,"bettxid %s -> vin0 %s/v%d -> %s\n",txid.GetHex().c_str(),vinTx.vin[0].prevout.hash.GetHex().c_str(),entropyvout,entropy.GetHex().c_str()); + //fprintf(stderr,"bettxid %s -> vin0 %s/v%d -> %s\n",txid.GetHex().c_str(),vinTx.vin[0].prevout.hash.GetHex().c_str(),entropyvout,entropy.GetHex().c_str()); if ( hentropy != hentropy2 ) { hentropy2 = DiceHashEntropy(entropy,vinTx.vin[0].prevout.hash,vinTx.vin[0].prevout.n,1); From e75be5869492b8b350e02d0ef5fe4414eefd2bb7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 05:43:38 -1100 Subject: [PATCH 055/135] -print --- src/cc/dice.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 5eb3605ae..1f9070d9f 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -391,7 +391,7 @@ void *dicefinish(void *_ptr) 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\n",iter,vin0_needed,n); + //fprintf(stderr,"iter.%d vin0_needed.%d got %d\n",iter,vin0_needed,n); m = 0; DL_FOREACH_SAFE(DICEFINISH_LIST,ptr,tmp) { @@ -406,7 +406,7 @@ void *dicefinish(void *_ptr) if ( ptr->txid != zeroid ) { CCduration(numblocks,ptr->txid); - fprintf(stderr,"numblocks %s %d\n",ptr->txid.GetHex().c_str(),numblocks); + //fprintf(stderr,"numblocks %s %d\n",ptr->txid.GetHex().c_str(),numblocks); if ( numblocks > 0 ) continue; } @@ -441,7 +441,7 @@ void *dicefinish(void *_ptr) } else { - 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)); + //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)); } } } From 6e555c9c158dbf09de9456c5681e1c0ae433a89d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 06:02:05 -1100 Subject: [PATCH 056/135] +print --- src/cc/dice.cpp | 2 +- src/komodo_bitcoind.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 1f9070d9f..038fb55bf 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -375,7 +375,7 @@ void *dicefinish(void *_ptr) if ( newblock != 0 && ptr->txid != zeroid ) { CCduration(numblocks,ptr->txid); - fprintf(stderr,"duration finish txid.%s\n",ptr->txid.GetHex().c_str()); + //fprintf(stderr,"duration finish txid.%s\n",ptr->txid.GetHex().c_str()); if ( numblocks == 0 ) mySenddicetransaction(ptr->rawtx,ptr->entropyused,ptr->entropyvout,ptr->bettxid,ptr->betTx,ptr->funcid,ptr); else continue; diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index eb5d02e76..4c633ede4 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1476,6 +1476,7 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) if ( ASSETCHAINS_COMMISSION != 0 ) { checktoshis = komodo_commission(pblock); + fprintf(stderr,"height.%d commission %.8f\n",height,(double)checktoshis/COIN); /*if ( checktoshis > 10000 && pblock->vtx[0].vout.size() != 2 ) return(-1); else*/ if ( checktoshis != 0 ) From fcdfc0ea32366c8ccad3d025da50ce177c8dfd03 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 06:13:50 -1100 Subject: [PATCH 057/135] Skip commission bout --- src/komodo_bitcoind.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 4c633ede4..e4678f90e 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1114,7 +1114,8 @@ uint64_t komodo_commission(const CBlock *pblock) { n = pblock->vtx[0].vout.size(); for (j=0; jvtx[0].vout[j].nValue; + if ( j != 1 ) + total += pblock->vtx[0].vout[j].nValue; } else { From 17d91e14f1324edbd2385cfb02bd14c42a981ddf Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 06:28:15 -1100 Subject: [PATCH 058/135] -print --- src/komodo_bitcoind.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index e4678f90e..f1ea95d7c 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1477,8 +1477,8 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) if ( ASSETCHAINS_COMMISSION != 0 ) { checktoshis = komodo_commission(pblock); - fprintf(stderr,"height.%d commission %.8f\n",height,(double)checktoshis/COIN); - /*if ( checktoshis > 10000 && pblock->vtx[0].vout.size() != 2 ) + //fprintf(stderr,"height.%d commission %.8f\n",height,(double)checktoshis/COIN); + /*if ( checktoshis > 10000 && pblock->vtx[0].vout.size() != 2 ) jl777: not sure why this was here return(-1); else*/ if ( checktoshis != 0 ) { From 2d853d1959c3d745c12c435ac994f774ae520f29 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 07:10:22 -1100 Subject: [PATCH 059/135] Change orphan handling --- src/cc/dice.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 038fb55bf..0a7d9eb02 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -363,11 +363,11 @@ void *dicefinish(void *_ptr) if ( myGetTransaction(ptr->txid,finishTx,hashBlock) == 0 ) { fprintf(stderr,"ORPHANED finish txid.%s\n",ptr->txid.GetHex().c_str()); - //dicefinish_delete(ptr); - //continue; - if ( ptr->rawtx.empty() == 0 ) - ptr->rawtx.clear(); - ptr->txid = zeroid; + dicefinish_delete(ptr); + continue; + //if ( ptr->rawtx.empty() == 0 ) + // ptr->rawtx.clear(); + //ptr->txid = zeroid; } } if ( ptr->bettxid_ready != 0 ) From e17d90abfc5da8da099478da3d2fc29f7eece54e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 07:30:59 -1100 Subject: [PATCH 060/135] Founders reward just on block subsidy --- src/cc/dice.cpp | 4 ++-- src/komodo_bitcoind.h | 5 +++-- src/main.cpp | 2 +- src/miner.cpp | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 0a7d9eb02..479229b4f 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -776,7 +776,7 @@ int32_t DiceIsWinner(uint256 &entropy,int32_t &entropyvout,uint256 txid,CTransac if ( hentropy != hentropy2 ) { hentropy2 = DiceHashEntropy(entropy,vinTx.vin[0].prevout.hash,vinTx.vin[0].prevout.n,1); - fprintf(stderr,"alt bettxid %s -> vin0 %s/v%d -> %s\n",txid.GetHex().c_str(),vinTx.vin[0].prevout.hash.GetHex().c_str(),entropyvout,entropy.GetHex().c_str()); + //fprintf(stderr,"alt bettxid %s -> vin0 %s/v%d -> %s\n",txid.GetHex().c_str(),vinTx.vin[0].prevout.hash.GetHex().c_str(),entropyvout,entropy.GetHex().c_str()); } if ( hentropy == hentropy2 ) { @@ -1156,7 +1156,7 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit { entropytxid = txid; entropyval = tx.vout[0].nValue; - fprintf(stderr,"funcid.%c first.%d entropytxid.%s val %.8f\n",funcid,first,txid.GetHex().c_str(),(double)entropyval/COIN); + //fprintf(stderr,"funcid.%c first.%d entropytxid.%s val %.8f\n",funcid,first,txid.GetHex().c_str(),(double)entropyval/COIN); first = 1; if (random) { fprintf(stderr, "chosen entropy on loop: %d\n",loops); diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index f1ea95d7c..c2f6ef933 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1106,12 +1106,13 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_ PoS stake must be without txfee and in the last tx in the block at vout[0] */ -uint64_t komodo_commission(const CBlock *pblock) +uint64_t komodo_commission(const CBlock *pblock,int32_t height) { int32_t i,j,n=0,txn_count; uint64_t commission,total = 0; txn_count = pblock->vtx.size(); if ( ASSETCHAINS_FOUNDERS != 0 ) { + return(GetBlockSubsidy(height,chainparams.GetConsensus())); n = pblock->vtx[0].vout.size(); for (j=0; j 10000 && pblock->vtx[0].vout.size() != 2 ) jl777: not sure why this was here return(-1); diff --git a/src/main.cpp b/src/main.cpp index 115920264..aa055068a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3129,7 +3129,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 ) { uint64_t checktoshis; - if ( (checktoshis= komodo_commission((CBlock *)&block)) != 0 ) + if ( (checktoshis= komodo_commission((CBlock *)&block,(int32_t)pindex->nHeight)) != 0 ) { if ( block.vtx[0].vout.size() == 2 && block.vtx[0].vout[1].nValue == checktoshis ) blockReward += checktoshis; diff --git a/src/miner.cpp b/src/miner.cpp index 71a22b7d8..65a00861b 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -119,7 +119,7 @@ int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33, int32_t komodo_pax_opreturn(int32_t height,uint8_t *opret,int32_t maxsize); int32_t komodo_baseid(char *origbase); int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_t nTime,int32_t dispflag); -uint64_t komodo_commission(const CBlock *block); +uint64_t komodo_commission(const CBlock *block,int32_t height); int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blocktimep,uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig); int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33); @@ -438,7 +438,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) txNew.vin[0].scriptSig = CScript() << nHeight << OP_0; pblock->vtx[0] = txNew; - if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block)) != 0 ) + if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0 ) { int32_t i; uint8_t *ptr; txNew.vout.resize(2); From e196f1aa9c45b2fe7d3a9b4de24a791dd3b30939 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 07:32:31 -1100 Subject: [PATCH 061/135] Params --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index c2f6ef933..7abaa298e 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1112,7 +1112,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) txn_count = pblock->vtx.size(); if ( ASSETCHAINS_FOUNDERS != 0 ) { - return(GetBlockSubsidy(height,chainparams.GetConsensus())); + return(GetBlockSubsidy(height,Params.GetConsensus())); n = pblock->vtx[0].vout.size(); for (j=0; j Date: Sat, 10 Nov 2018 07:33:19 -1100 Subject: [PATCH 062/135] () --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 7abaa298e..2c885b546 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1112,7 +1112,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) txn_count = pblock->vtx.size(); if ( ASSETCHAINS_FOUNDERS != 0 ) { - return(GetBlockSubsidy(height,Params.GetConsensus())); + return(GetBlockSubsidy(height,Params().GetConsensus())); n = pblock->vtx[0].vout.size(); for (j=0; j Date: Sat, 10 Nov 2018 07:34:43 -1100 Subject: [PATCH 063/135] Apply percentage --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 2c885b546..0dec50eb6 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1112,7 +1112,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) txn_count = pblock->vtx.size(); if ( ASSETCHAINS_FOUNDERS != 0 ) { - return(GetBlockSubsidy(height,Params().GetConsensus())); + return((GetBlockSubsidy(height,Params().GetConsensus()) * ASSETCHAINS_COMMISSION) / COIN); n = pblock->vtx[0].vout.size(); for (j=0; j Date: Sat, 10 Nov 2018 08:28:27 -1100 Subject: [PATCH 064/135] +print --- src/komodo_bitcoind.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 0dec50eb6..414959455 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1108,11 +1108,13 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_ uint64_t komodo_commission(const CBlock *pblock,int32_t height) { - int32_t i,j,n=0,txn_count; uint64_t commission,total = 0; + int32_t i,j,n=0,txn_count; int64_t nSubsidy; uint64_t commission,total = 0; txn_count = pblock->vtx.size(); if ( ASSETCHAINS_FOUNDERS != 0 ) { - return((GetBlockSubsidy(height,Params().GetConsensus()) * ASSETCHAINS_COMMISSION) / COIN); + nSubsidy = GetBlockSubsidy(height,Params().GetConsensus()); + fprintf(stderr,"nSubsidy %.8f prod %llu\n",(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); + return((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); n = pblock->vtx[0].vout.size(); for (j=0; j 10000 && pblock->vtx[0].vout.size() != 2 ) jl777: not sure why this was here return(-1); else*/ if ( checktoshis != 0 ) From 1c31ecbaa84bd6ca147cd9950f7e28047fb0785e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 08:29:04 -1100 Subject: [PATCH 065/135] -print --- src/rpccrosschain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpccrosschain.cpp b/src/rpccrosschain.cpp index 2059ab452..02ab34c0d 100644 --- a/src/rpccrosschain.cpp +++ b/src/rpccrosschain.cpp @@ -51,7 +51,7 @@ UniValue assetchainproof(const UniValue& params, bool fHelp) UniValue crosschainproof(const UniValue& params, bool fHelp) { UniValue ret(UniValue::VOBJ); - fprintf(stderr,"crosschainproof needs to be implemented\n"); + //fprintf(stderr,"crosschainproof needs to be implemented\n"); return(ret); } From 7b6f5044deb78b2c6a5b0679ef8d20d5ffd81105 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 08:31:25 -1100 Subject: [PATCH 066/135] +print --- src/komodo_bitcoind.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 414959455..966dcd6a2 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1106,6 +1106,8 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_ PoS stake must be without txfee and in the last tx in the block at vout[0] */ +CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams); + uint64_t komodo_commission(const CBlock *pblock,int32_t height) { int32_t i,j,n=0,txn_count; int64_t nSubsidy; uint64_t commission,total = 0; @@ -1113,7 +1115,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) if ( ASSETCHAINS_FOUNDERS != 0 ) { nSubsidy = GetBlockSubsidy(height,Params().GetConsensus()); - fprintf(stderr,"nSubsidy %.8f prod %llu\n",(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); + fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); return((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); n = pblock->vtx[0].vout.size(); for (j=0; j Date: Sat, 10 Nov 2018 08:38:24 -1100 Subject: [PATCH 067/135] Fix p2pkh check --- src/komodo_bitcoind.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 966dcd6a2..11c9cf7b9 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1478,7 +1478,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) { - int64_t checktoshis=0; uint8_t *script; + int64_t checktoshis=0; uint8_t *script; int32_t scriptlen,matched = 0; if ( ASSETCHAINS_COMMISSION != 0 ) { checktoshis = komodo_commission(pblock,height); @@ -1488,10 +1488,16 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) else*/ if ( checktoshis != 0 ) { script = (uint8_t *)pblock->vtx[0].vout[1].scriptPubKey.data(); - if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) + scriptlen = (int32_t)pblock->vtx[0].vout[1].scriptPubKey.size(); + if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) == 0 ) + matched = 1; + else if ( scriptlen == 25 && script[0] == OP_DUP && script[1] == OP_HASH160 && script[23] == OP_EQUALVERIFY && script[24] == OP_CHECKSIG && memcmp(script+2,ASSETCHAINS_OVERRIDE_PUBKEYHASH,20) == 0 ) + matched = 2; + if ( matched == 0 ) { - if ( script[0] != 25 || script[0] != OP_DUP || script[1] != OP_HASH160 || script[23] != OP_EQUALVERIFY || script[24] != OP_CHECKSIG || memcmp(script+2,ASSETCHAINS_OVERRIDE_PUBKEYHASH,20) != 0 ) + fprintf(stderr,"payment to wrong pubkey\n"); return(-1); + } if ( pblock->vtx[0].vout[1].nValue != checktoshis ) { From 0df9cddf668f519e2aa0a8049bc863033c7882d3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 08:40:10 -1100 Subject: [PATCH 068/135] Fix --- src/komodo_bitcoind.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 11c9cf7b9..c2892865c 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1491,7 +1491,7 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) scriptlen = (int32_t)pblock->vtx[0].vout[1].scriptPubKey.size(); if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) == 0 ) matched = 1; - else if ( scriptlen == 25 && script[0] == OP_DUP && script[1] == OP_HASH160 && script[23] == OP_EQUALVERIFY && script[24] == OP_CHECKSIG && memcmp(script+2,ASSETCHAINS_OVERRIDE_PUBKEYHASH,20) == 0 ) + else if ( scriptlen == 25 && script[0] == OP_DUP && script[1] == OP_HASH160 && script[2] == 20 && script[23] == OP_EQUALVERIFY && script[24] == OP_CHECKSIG && memcmp(script+3,ASSETCHAINS_OVERRIDE_PUBKEYHASH,20) == 0 ) matched = 2; if ( matched == 0 ) { From 9328dae04f654bec3d8d828bdb1ae6b5a9281171 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 08:51:13 -1100 Subject: [PATCH 069/135] Refund orphans --- src/cc/dice.cpp | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 479229b4f..f1914dc53 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -363,11 +363,29 @@ void *dicefinish(void *_ptr) if ( myGetTransaction(ptr->txid,finishTx,hashBlock) == 0 ) { fprintf(stderr,"ORPHANED finish txid.%s\n",ptr->txid.GetHex().c_str()); - dicefinish_delete(ptr); + if ( ptr->rawtx.empty() == 0 ) + ptr->rawtx.clear(); + ptr->txid = zeroid; + unstringbits(name,ptr->sbits); + result = 0; + res = DiceBetFinish(ptr->funcid,entropyused,entropyvout,&result,0,name,ptr->fundingtxid,ptr->bettxid,ptr->iswin,zeroid,-2); + if ( ptr->entropyused == zeroid ) + { + ptr->entropyused = entropyused; + ptr->entropyvout = entropyvout; + } + if ( entropyused != ptr->entropyused || entropyvout != ptr->entropyvout ) + { + fprintf(stderr,"WARNING entropy %s != %s || %d != %d\n",entropyused.GetHex().c_str(),ptr->entropyused.GetHex().c_str(),entropyvout,ptr->entropyvout); + } + if ( result > 0 ) + { + ptr->rawtx = res; + fprintf(stderr,"send refund!\n"); + mySenddicetransaction(ptr->rawtx,ptr->entropyused,ptr->entropyvout,ptr->bettxid,ptr->betTx,ptr->funcid,ptr); + } + //dicefinish_delete(ptr); continue; - //if ( ptr->rawtx.empty() == 0 ) - // ptr->rawtx.clear(); - //ptr->txid = zeroid; } } if ( ptr->bettxid_ready != 0 ) @@ -1495,12 +1513,14 @@ std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t &entropyv if ( winlosetimeout != 0 ) // dealernode { entropyused = hentropyproof; + if ( vin0vout == -2 ) + retval = -1; /*if ( iswin == 0 ) { retval = -1; fprintf(stderr,"invalid dicebet %s\n",bettxid.GetHex().c_str()); } else retval = 0;*/ - if ( (retval= DiceEntropyUsed(oldbetTx,oldbettxid,oldentropyvout,entropyused,bettxid,betTx,entropyvout)) != 0 ) + if ( retval < 0 || (retval= DiceEntropyUsed(oldbetTx,oldbettxid,oldentropyvout,entropyused,bettxid,betTx,entropyvout)) != 0 ) { if ( retval < 0 ) { From 4ee48bc646fbb15bdf909453cfa58de36e83aa4b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 08:56:32 -1100 Subject: [PATCH 070/135] Print script --- src/komodo_bitcoind.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index c2892865c..43f8230b7 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1495,7 +1495,9 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) matched = 2; if ( matched == 0 ) { - fprintf(stderr,"payment to wrong pubkey\n"); + for (i=0; i<25; i++) + fprintf(stderr,"%02x",script[i]); + fprintf(stderr," payment to wrong pubkey scriptlen.%d\n",scriptlen); return(-1); } From a5191f399b84f1e4981d81698933a60c61b992f9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 08:58:35 -1100 Subject: [PATCH 071/135] Fix --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index f1914dc53..f27dbcb0e 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1463,7 +1463,7 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t &entropyvout,int32_t *resultp,uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettxid,int32_t winlosetimeout,uint256 vin0txid,int32_t vin0vout) { - CMutableTransaction mtx; CScript scriptPubKey,fundingPubKey; CTransaction oldbetTx,betTx,entropyTx; uint256 hentropyproof,entropytxid,hashBlock,bettorentropy,entropy,hentropy,oldbettxid; CPubKey mypk,dicepk,fundingpk; struct CCcontract_info *cp,C; int64_t inputs=0,CCchange=0,odds,fundsneeded,minbet,maxbet,maxodds,timeoutblocks; int32_t oldentropyvout,retval,iswin=0; uint64_t entropyval,sbits; + CMutableTransaction mtx; CScript scriptPubKey,fundingPubKey; CTransaction oldbetTx,betTx,entropyTx; uint256 hentropyproof,entropytxid,hashBlock,bettorentropy,entropy,hentropy,oldbettxid; CPubKey mypk,dicepk,fundingpk; struct CCcontract_info *cp,C; int64_t inputs=0,CCchange=0,odds,fundsneeded,minbet,maxbet,maxodds,timeoutblocks; int32_t oldentropyvout,retval=0,iswin=0; uint64_t entropyval,sbits; entropyused = zeroid; *resultp = 0; funcid = 0; From e1e4bc52772c2061cc9c6d8c8501bb8a85ab6460 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 08:59:27 -1100 Subject: [PATCH 072/135] Fix --- src/komodo_bitcoind.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 43f8230b7..ddaea9460 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1495,6 +1495,7 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) matched = 2; if ( matched == 0 ) { + int32_t i; for (i=0; i<25; i++) fprintf(stderr,"%02x",script[i]); fprintf(stderr," payment to wrong pubkey scriptlen.%d\n",scriptlen); From 78ba3255a7de866322b4175d4fbe14e97cf11bf4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 09:09:55 -1100 Subject: [PATCH 073/135] newblock != 0 --- src/cc/dice.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index f27dbcb0e..a6e8e6146 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -352,13 +352,13 @@ void *dicefinish(void *_ptr) else if ( mytxid_inmempool(ptr->bettxid) != 0 ) ptr->bettxid_ready = (uint32_t)time(NULL); } - else if ( myGetTransaction(ptr->bettxid,betTx,hashBlock) == 0 ) + else if ( newblock != 0 && myGetTransaction(ptr->bettxid,betTx,hashBlock) == 0 ) { fprintf(stderr,"ORPHANED bettxid.%s\n",ptr->bettxid.GetHex().c_str()); dicefinish_delete(ptr); continue; } - else if ( ptr->txid != zeroid ) + else if ( newblock != 0 && ptr->txid != zeroid ) { if ( myGetTransaction(ptr->txid,finishTx,hashBlock) == 0 ) { @@ -384,7 +384,6 @@ void *dicefinish(void *_ptr) fprintf(stderr,"send refund!\n"); mySenddicetransaction(ptr->rawtx,ptr->entropyused,ptr->entropyvout,ptr->bettxid,ptr->betTx,ptr->funcid,ptr); } - //dicefinish_delete(ptr); continue; } } From 27c8492618a6920c3da4f036bf95bbd1464af38e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 09:25:26 -1100 Subject: [PATCH 074/135] Orphaned count --- src/cc/dice.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index a6e8e6146..4da8e2d7b 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -113,12 +113,12 @@ struct dicefinish_utxo { uint256 txid; int32_t vout; }; struct dicefinish_info { struct dicefinish_info *prev,*next; + CTransaction betTx; uint256 fundingtxid,bettxid,entropyused,txid; uint64_t sbits; int64_t winamount; - int32_t iswin,entropyvout; + int32_t iswin,entropyvout,orphaned; uint32_t bettxid_ready,revealed; - CTransaction betTx; std::string rawtx; uint8_t funcid; } *DICEFINISH_LIST; @@ -362,7 +362,10 @@ void *dicefinish(void *_ptr) { if ( myGetTransaction(ptr->txid,finishTx,hashBlock) == 0 ) { - fprintf(stderr,"ORPHANED finish txid.%s\n",ptr->txid.GetHex().c_str()); + ptr->orphaned++; + fprintf(stderr,"ORPHANED.%d finish txid.%s\n",ptr->orphaned,ptr->txid.GetHex().c_str()); + if ( ptr->orphaned < 10 ) + continue; if ( ptr->rawtx.empty() == 0 ) ptr->rawtx.clear(); ptr->txid = zeroid; From e2445cb37b765717c1e44ec1df40a88367cb6535 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 09:49:18 -1100 Subject: [PATCH 075/135] -ac_script --- src/komodo_globals.h | 4 ++-- src/komodo_utils.h | 14 ++++++++++---- src/miner.cpp | 19 ++++++++++++------- 3 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 78f1e1cac..e2cbedd33 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -47,8 +47,8 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; -std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY; -uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_FOUNDERS; +std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB; +uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_FOUNDERS,ASSETCHAINS_SCRIPTPUBKEY[256]; char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096]; uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 09c5622af..8a4fff6dd 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1563,6 +1563,7 @@ void komodo_args(char *argv0) ASSETCHAINS_DECAY = GetArg("-ac_decay",0); ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0); ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey",""); + ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script",""); if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 ) ASSETCHAINS_STAKED = 100; if ( ASSETCHAINS_STAKED != 0 && ASSETCHAINS_PRIVATE != 0 ) @@ -1585,13 +1586,18 @@ void komodo_args(char *argv0) ASSETCHAINS_DECAY = 0; printf("ASSETCHAINS_DECAY cant be more than 100000000\n"); } - if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 ) + if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 || (ASSETCHAINS_SCRIPTPUB.size() > 16 && ASSETCHAINS_SCRIPTPUB.size() < 256*2) ) { - decode_hex(ASSETCHAINS_OVERRIDE_PUBKEY33,33,(char *)ASSETCHAINS_OVERRIDE_PUBKEY.c_str()); - calc_rmd160_sha256(ASSETCHAINS_OVERRIDE_PUBKEYHASH,ASSETCHAINS_OVERRIDE_PUBKEY33,33); + if ( ASSETCHAINS_OVERRIDE_PUBKEY.c_str() == 66 ) + { + decode_hex(ASSETCHAINS_OVERRIDE_PUBKEY33,33,(char *)ASSETCHAINS_OVERRIDE_PUBKEY.c_str()); + calc_rmd160_sha256(ASSETCHAINS_OVERRIDE_PUBKEYHASH,ASSETCHAINS_OVERRIDE_PUBKEY33,33); + } + if ( ASSETCHAINS_SCRIPTPUB.size() > 0 ) + decode_hex(ASSETCHAINS_SCRIPTPUBKEY,(int32_t)ASSETCHAINS_SCRIPTPUB.size()/2,(char *)ASSETCHAINS_SCRIPTPUB.c_str()); if ( ASSETCHAINS_COMMISSION == 0 && ASSETCHAINS_FOUNDERS != 0 ) { - ASSETCHAINS_COMMISSION = 35000000; + ASSETCHAINS_COMMISSION = 53846154; // maps to 35% printf("ASSETCHAINS_COMMISSION defaulted to 35%% when founders reward active\n"); } } diff --git a/src/miner.cpp b/src/miner.cpp index 65a00861b..c604c59e2 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -438,17 +438,22 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) txNew.vin[0].scriptSig = CScript() << nHeight << OP_0; pblock->vtx[0] = txNew; - if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0 ) + if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUBKEY[0] != 0) && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0 ) { int32_t i; uint8_t *ptr; txNew.vout.resize(2); txNew.vout[1].nValue = commission; - txNew.vout[1].scriptPubKey.resize(35); - ptr = (uint8_t *)txNew.vout[1].scriptPubKey.data(); - ptr[0] = 33; - for (i=0; i<33; i++) - ptr[i+1] = ASSETCHAINS_OVERRIDE_PUBKEY33[i]; - ptr[34] = OP_CHECKSIG; + if ( ASSETCHAINS_SCRIPTPUBKEY[0] != 0 ) + txNew.vout[1].scriptPubKey = CScript() << ParseHex(ASSETCHAINS_SCRIPTPUB); + else + { + txNew.vout[1].scriptPubKey.resize(35); + ptr = (uint8_t *)txNew.vout[1].scriptPubKey.data(); + ptr[0] = 33; + for (i=0; i<33; i++) + ptr[i+1] = ASSETCHAINS_OVERRIDE_PUBKEY33[i]; + ptr[34] = OP_CHECKSIG; + } //printf("autocreate commision vout\n"); pblock->vtx[0] = txNew; } From 1d0ca47a217dbca60624114d75d3f3661eaca387 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 09:51:24 -1100 Subject: [PATCH 076/135] Fix --- src/komodo_utils.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 8a4fff6dd..77bcecd84 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1588,7 +1588,7 @@ void komodo_args(char *argv0) } if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 || (ASSETCHAINS_SCRIPTPUB.size() > 16 && ASSETCHAINS_SCRIPTPUB.size() < 256*2) ) { - if ( ASSETCHAINS_OVERRIDE_PUBKEY.c_str() == 66 ) + if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 ) { decode_hex(ASSETCHAINS_OVERRIDE_PUBKEY33,33,(char *)ASSETCHAINS_OVERRIDE_PUBKEY.c_str()); calc_rmd160_sha256(ASSETCHAINS_OVERRIDE_PUBKEYHASH,ASSETCHAINS_OVERRIDE_PUBKEY33,33); From d71ca09221c2dde851f1c07936c53f850f8e9557 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 09:53:26 -1100 Subject: [PATCH 077/135] Fix --- src/miner.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index c604c59e2..45b7da2e1 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -109,7 +109,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, extern int32_t KOMODO_MININGTHREADS,KOMODO_LONGESTCHAIN,ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; extern uint64_t ASSETCHAINS_REWARD,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; -extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY; +extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY,ASSETCHAINS_SCRIPTPUB; void vcalc_sha256(char deprecated[(256 >> 3) * 2 + 1],uint8_t hash[256 >> 3],uint8_t *src,int32_t len); extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33]; @@ -438,12 +438,12 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) txNew.vin[0].scriptSig = CScript() << nHeight << OP_0; pblock->vtx[0] = txNew; - if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUBKEY[0] != 0) && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0 ) + if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() != 0) && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0 ) { int32_t i; uint8_t *ptr; txNew.vout.resize(2); txNew.vout[1].nValue = commission; - if ( ASSETCHAINS_SCRIPTPUBKEY[0] != 0 ) + if ( ASSETCHAINS_SCRIPTPUB.size() != 0 ) txNew.vout[1].scriptPubKey = CScript() << ParseHex(ASSETCHAINS_SCRIPTPUB); else { From bba4bf660773f8d3b776f102d2ddb4db7e4a4798 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 09:55:10 -1100 Subject: [PATCH 078/135] Fix --- src/komodo_globals.h | 2 +- src/komodo_utils.h | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/komodo_globals.h b/src/komodo_globals.h index e2cbedd33..453576b8b 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -48,7 +48,7 @@ int COINBASE_MATURITY = _COINBASE_MATURITY;//100; int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1; int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB; -uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_FOUNDERS,ASSETCHAINS_SCRIPTPUBKEY[256]; +uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_FOUNDERS; char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096]; uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 77bcecd84..f817d0cdd 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1586,15 +1586,13 @@ void komodo_args(char *argv0) ASSETCHAINS_DECAY = 0; printf("ASSETCHAINS_DECAY cant be more than 100000000\n"); } - if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 || (ASSETCHAINS_SCRIPTPUB.size() > 16 && ASSETCHAINS_SCRIPTPUB.size() < 256*2) ) + if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 || ASSETCHAINS_SCRIPTPUB.size() > 1 ) { if ( strlen(ASSETCHAINS_OVERRIDE_PUBKEY.c_str()) == 66 ) { decode_hex(ASSETCHAINS_OVERRIDE_PUBKEY33,33,(char *)ASSETCHAINS_OVERRIDE_PUBKEY.c_str()); calc_rmd160_sha256(ASSETCHAINS_OVERRIDE_PUBKEYHASH,ASSETCHAINS_OVERRIDE_PUBKEY33,33); } - if ( ASSETCHAINS_SCRIPTPUB.size() > 0 ) - decode_hex(ASSETCHAINS_SCRIPTPUBKEY,(int32_t)ASSETCHAINS_SCRIPTPUB.size()/2,(char *)ASSETCHAINS_SCRIPTPUB.c_str()); if ( ASSETCHAINS_COMMISSION == 0 && ASSETCHAINS_FOUNDERS != 0 ) { ASSETCHAINS_COMMISSION = 53846154; // maps to 35% From 1d8477869540354f54acabc3b8db9a91c30b479e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 09:58:57 -1100 Subject: [PATCH 079/135] Set ac hash --- src/komodo_utils.h | 6 ++++-- src/miner.cpp | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index f817d0cdd..838461ee2 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1503,7 +1503,7 @@ void komodo_args(char *argv0) { extern int64_t MAX_MONEY; extern const char *Notaries_elected1[][2]; - std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[256],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,baseid,len,n,extralen = 0; + std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[8192],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,baseid,len,n,extralen = 0; IS_KOMODO_NOTARY = GetBoolArg("-notary", false); if ( GetBoolArg("-gen", false) != 0 ) KOMODO_MININGTHREADS = GetArg("-genproclimit",1); @@ -1612,7 +1612,7 @@ void komodo_args(char *argv0) printf("ASSETCHAINS_FOUNDERS needs an ASETCHAINS_OVERRIDE_PUBKEY\n"); } } - if ( ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 ) + if ( ASSETCHAINS_ENDSUBSIDY != 0 || ASSETCHAINS_REWARD != 0 || ASSETCHAINS_HALVING != 0 || ASSETCHAINS_DECAY != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 ) { fprintf(stderr,"end.%llu blocks, reward %.8f halving.%llu blocks, decay.%llu perc %.4f%% ac_pub=[%02x...]\n",(long long)ASSETCHAINS_ENDSUBSIDY,dstr(ASSETCHAINS_REWARD),(long long)ASSETCHAINS_HALVING,(long long)ASSETCHAINS_DECAY,dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0]); extraptr = extrabuf; @@ -1625,6 +1625,8 @@ void komodo_args(char *argv0) extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val); if ( ASSETCHAINS_FOUNDERS != 0 ) extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS),(void *)&ASSETCHAINS_FOUNDERS); + if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) + extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str()); } addn = GetArg("-seednode",""); if ( strlen(addn.c_str()) > 0 ) diff --git a/src/miner.cpp b/src/miner.cpp index 45b7da2e1..a8c6e087c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -438,12 +438,12 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount) txNew.vin[0].scriptSig = CScript() << nHeight << OP_0; pblock->vtx[0] = txNew; - if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() != 0) && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0 ) + if ( nHeight > 1 && ASSETCHAINS_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && ASSETCHAINS_COMMISSION != 0 && (commission= komodo_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0 ) { int32_t i; uint8_t *ptr; txNew.vout.resize(2); txNew.vout[1].nValue = commission; - if ( ASSETCHAINS_SCRIPTPUB.size() != 0 ) + if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) txNew.vout[1].scriptPubKey = CScript() << ParseHex(ASSETCHAINS_SCRIPTPUB); else { From 84efe780fe0575ab950e40f7fe3c48a86e3da343 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 10:05:24 -1100 Subject: [PATCH 080/135] Check ASSETCHAINS_SCRIPTPUB --- src/komodo_bitcoind.h | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index ddaea9460..25aa09eea 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1478,7 +1478,7 @@ int32_t komodo_is_PoSblock(int32_t slowflag,int32_t height,CBlock *pblock,arith_ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) { - int64_t checktoshis=0; uint8_t *script; int32_t scriptlen,matched = 0; + int64_t checktoshis=0; uint8_t *script,scripthex[8192]; int32_t scriptlen,matched = 0; if ( ASSETCHAINS_COMMISSION != 0 ) { checktoshis = komodo_commission(pblock,height); @@ -1489,16 +1489,25 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height) { script = (uint8_t *)pblock->vtx[0].vout[1].scriptPubKey.data(); scriptlen = (int32_t)pblock->vtx[0].vout[1].scriptPubKey.size(); - if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) == 0 ) - matched = 1; + if ( ASSETCHAINS_SCRIPTPUB.size() > 1 ) + { + if ( ASSETCHAINS_SCRIPTPUB.size()/2 == scriptlen && scriptlen < sizeof(scripthex) ) + { + decode_hex(scripthex,scriptlen,(char *)ASSETCHAINS_SCRIPTPUB.c_str()); + if ( memcmp(scripthex,script,scriptlen) == 0 ) + matched = scriptlen; + } + } + else if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) == 0 ) + matched = 35; else if ( scriptlen == 25 && script[0] == OP_DUP && script[1] == OP_HASH160 && script[2] == 20 && script[23] == OP_EQUALVERIFY && script[24] == OP_CHECKSIG && memcmp(script+3,ASSETCHAINS_OVERRIDE_PUBKEYHASH,20) == 0 ) - matched = 2; + matched = 25; if ( matched == 0 ) { int32_t i; for (i=0; i<25; i++) fprintf(stderr,"%02x",script[i]); - fprintf(stderr," payment to wrong pubkey scriptlen.%d\n",scriptlen); + fprintf(stderr," payment to wrong pubkey scriptlen.%d, scriptpub[%d]\n",scriptlen,(int32_t)ASSETCHAINS_SCRIPTPUB.size()/2); return(-1); } From 064a97f021c3c3b142e7634d9eddfd18601085cd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 10:25:34 -1100 Subject: [PATCH 081/135] MofN -> Heir --- src/Makefile.am | 2 +- src/cc/CC made easy | 2 +- src/cc/CCMofN.h | 10 ++--- src/cc/CCcustom.cpp | 30 ++++++------- src/cc/eval.h | 2 +- src/cc/{MofN.cpp => heir.cpp} | 81 ++++++++++++++--------------------- src/rpcserver.cpp | 4 +- src/rpcserver.h | 2 +- src/wallet/rpcwallet.cpp | 8 ++-- 9 files changed, 63 insertions(+), 78 deletions(-) rename src/cc/{MofN.cpp => heir.cpp} (72%) diff --git a/src/Makefile.am b/src/Makefile.am index 5252b1fa0..694d67278 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -267,7 +267,7 @@ libbitcoin_server_a_SOURCES = \ cc/dice.cpp \ cc/lotto.cpp \ cc/fsm.cpp \ - cc/MofN.cpp \ + cc/heir.cpp \ cc/oracles.cpp \ cc/prices.cpp \ cc/pegs.cpp \ diff --git a/src/cc/CC made easy b/src/cc/CC made easy index 158c2907a..3f15a6b6b 100644 --- a/src/cc/CC made easy +++ b/src/cc/CC made easy @@ -95,7 +95,7 @@ EVAL(EVAL_DICE, 0xe6) \ EVAL(EVAL_FSM, 0xe7) \ EVAL(EVAL_AUCTION, 0xe8) \ EVAL(EVAL_LOTTO, 0xe9) \ -EVAL(EVAL_MOFN, 0xea) \ +EVAL(EVAL_HEIR, 0xea) \ EVAL(EVAL_CHANNELS, 0xeb) \ EVAL(EVAL_ORACLES, 0xec) \ EVAL(EVAL_PRICES, 0xed) \ diff --git a/src/cc/CCMofN.h b/src/cc/CCMofN.h index 170200d77..c86bf3b6b 100644 --- a/src/cc/CCMofN.h +++ b/src/cc/CCMofN.h @@ -14,16 +14,16 @@ ******************************************************************************/ -#ifndef CC_MOFN_H -#define CC_MOFN_H +#ifndef CC_HEIR_H +#define CC_HEIR_H #include "CCinclude.h" -#define EVAL_MOFN 0xea +#define EVAL_HEIR 0xea -bool MofNValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx); +bool HeirValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx); // CCcustom -UniValue MofNInfo(); +UniValue HeirInfo(); #endif diff --git a/src/cc/CCcustom.cpp b/src/cc/CCcustom.cpp index 71644686b..3cd3625e7 100644 --- a/src/cc/CCcustom.cpp +++ b/src/cc/CCcustom.cpp @@ -21,7 +21,7 @@ #include "CCauction.h" #include "CClotto.h" #include "CCfsm.h" -#include "CCMofN.h" +#include "CCHeir.h" #include "CCchannels.h" #include "CCOracles.h" #include "CCPrices.h" @@ -133,13 +133,13 @@ uint8_t AuctionCCpriv[32] = { 0x8c, 0x1b, 0xb7, 0x8c, 0x02, 0xa3, 0x9d, 0x21, 0x #undef FUNCNAME #undef EVALCODE -// MofN -#define FUNCNAME IsMofNInput -#define EVALCODE EVAL_MOFN -const char *MofNCCaddr = "RDVHcSekmXgeYBqRupNTmqo3Rn8QRXNduy"; -const char *MofNNormaladdr = "RTPwUjKYECcGn6Y4KYChLhgaht1RSU4jwf"; -char MofNCChexstr[67] = { "03c91bef3d7cc59c3a89286833a3446b29e52a5e773f738a1ad2b09785e5f4179e" }; -uint8_t MofNCCpriv[32] = { 0x9d, 0xa1, 0xf8, 0xf7, 0xba, 0x0a, 0x91, 0x36, 0x89, 0x9a, 0x86, 0x30, 0x63, 0x20, 0xd7, 0xdf, 0xaa, 0x35, 0xe3, 0x99, 0x32, 0x2b, 0x63, 0xc0, 0x66, 0x9c, 0x93, 0xc4, 0x5e, 0x9d, 0xb9, 0xce }; +// Heir +#define FUNCNAME IsHeirInput +#define EVALCODE EVAL_HEIR +const char *HeirCCaddr = "RDVHcSekmXgeYBqRupNTmqo3Rn8QRXNduy"; +const char *HeirNormaladdr = "RTPwUjKYECcGn6Y4KYChLhgaht1RSU4jwf"; +char HeirCChexstr[67] = { "03c91bef3d7cc59c3a89286833a3446b29e52a5e773f738a1ad2b09785e5f4179e" }; +uint8_t HeirCCpriv[32] = { 0x9d, 0xa1, 0xf8, 0xf7, 0xba, 0x0a, 0x91, 0x36, 0x89, 0x9a, 0x86, 0x30, 0x63, 0x20, 0xd7, 0xdf, 0xaa, 0x35, 0xe3, 0x99, 0x32, 0x2b, 0x63, 0xc0, 0x66, 0x9c, 0x93, 0xc4, 0x5e, 0x9d, 0xb9, 0xce }; #include "CCcustom.inc" #undef FUNCNAME #undef EVALCODE @@ -282,13 +282,13 @@ struct CCcontract_info *CCinit(struct CCcontract_info *cp,uint8_t evalcode) cp->validate = AuctionValidate; cp->ismyvin = IsAuctionInput; break; - case EVAL_MOFN: - strcpy(cp->unspendableCCaddr,MofNCCaddr); - strcpy(cp->normaladdr,MofNNormaladdr); - strcpy(cp->CChexstr,MofNCChexstr); - memcpy(cp->CCpriv,MofNCCpriv,32); - cp->validate = MofNValidate; - cp->ismyvin = IsMofNInput; + case EVAL_HEIR: + strcpy(cp->unspendableCCaddr,HeirCCaddr); + strcpy(cp->normaladdr,HeirNormaladdr); + strcpy(cp->CChexstr,HeirCChexstr); + memcpy(cp->CCpriv,HeirCCpriv,32); + cp->validate = HeirValidate; + cp->ismyvin = IsHeirInput; break; case EVAL_CHANNELS: strcpy(cp->unspendableCCaddr,ChannelsCCaddr); diff --git a/src/cc/eval.h b/src/cc/eval.h index 9ff0ca623..9c788422e 100644 --- a/src/cc/eval.h +++ b/src/cc/eval.h @@ -47,7 +47,7 @@ EVAL(EVAL_FSM, 0xe7) \ EVAL(EVAL_AUCTION, 0xe8) \ EVAL(EVAL_LOTTO, 0xe9) \ - EVAL(EVAL_MOFN, 0xea) \ + EVAL(EVAL_HEIR, 0xea) \ EVAL(EVAL_CHANNELS, 0xeb) \ EVAL(EVAL_ORACLES, 0xec) \ EVAL(EVAL_PRICES, 0xed) \ diff --git a/src/cc/MofN.cpp b/src/cc/heir.cpp similarity index 72% rename from src/cc/MofN.cpp rename to src/cc/heir.cpp index c22c48263..d4aab932a 100644 --- a/src/cc/MofN.cpp +++ b/src/cc/heir.cpp @@ -13,30 +13,15 @@ * * ******************************************************************************/ -#include "CCMofN.h" +#include "CCHeir.h" /* - The idea of MofN CC is to allow non-interactive multisig, preferably in a cross chain compatible way, ie. for actual bitcoin multisig. - - full redeemscript in an initial tx with opreturn - ability to post partial signatures and construct a full transaction from M such partial signatures - a new transaction would refer to the initialtx and other partial would refer to both - - There is no need for a CC contract to use it for normal multisig as normal multisig transactions are already supported. - - In order to take advantage of CC powers, we can create a more powerful multisig using shamir's secret MofN (up to 255) algo to allow spends. Using the same non-interactive partial signing is possible. also, in addition to spending, data payload can have additional data that is also revealed when the funds are spent. - - rpc calls needed: - 1) create msig address (normal or shamir) - 2) post payment with partial sig - 3) add partial sig to 2) - 4) combine and submit M partial sigs - + The idea of Heir CC is to allow crypto inheritance */ // start of consensus code -int64_t IsMofNvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) +int64_t IsHeirvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) { char destaddr[64]; if ( tx.vout[v].scriptPubKey.IsPayToCryptoCondition() != 0 ) @@ -47,7 +32,7 @@ int64_t IsMofNvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) return(0); } -bool MofNExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) +bool HeirExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx,int32_t minage,uint64_t txfee) { static uint256 zerohash; CTransaction vinTx; uint256 hashBlock,activehash; int32_t i,numvins,numvouts; int64_t inputs=0,outputs=0,assetoshis; @@ -65,8 +50,8 @@ bool MofNExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction & { //fprintf(stderr,"vini.%d check hash and vout\n",i); if ( hashBlock == zerohash ) - return eval->Invalid("cant MofN from mempool"); - if ( (assetoshis= IsMofNvout(cp,vinTx,tx.vin[i].prevout.n)) != 0 ) + return eval->Invalid("cant Heir from mempool"); + if ( (assetoshis= IsHeirvout(cp,vinTx,tx.vin[i].prevout.n)) != 0 ) inputs += assetoshis; } } @@ -74,7 +59,7 @@ bool MofNExactAmounts(struct CCcontract_info *cp,Eval* eval,const CTransaction & for (i=0; i origpubkey; CTransaction vintx; int32_t vout,n = 0; @@ -140,7 +125,7 @@ int64_t AddMofNInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKe // no need to prevent dup if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { - if ( (nValue= IsMofNvout(cp,vintx,vout)) > 1000000 && myIsutxo_spentinmempool(txid,vout) == 0 ) + if ( (nValue= IsHeirvout(cp,vintx,vout)) > 1000000 && myIsutxo_spentinmempool(txid,vout) == 0 ) { if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); @@ -155,27 +140,27 @@ int64_t AddMofNInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKe return(totalinputs); } -std::string MofNGet(uint64_t txfee,int64_t nValue) +std::string HeirGet(uint64_t txfee,int64_t nValue) { - CMutableTransaction mtx,tmpmtx; CPubKey mypk,mofnpk; int64_t inputs,CCchange=0; struct CCcontract_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; - cp = CCinit(&C,EVAL_MOFN); + CMutableTransaction mtx,tmpmtx; CPubKey mypk,Heirpk; int64_t inputs,CCchange=0; struct CCcontract_info *cp,C; std::string rawhex; uint32_t j; int32_t i,len; uint8_t buf[32768]; bits256 hash; + cp = CCinit(&C,EVAL_HEIR); if ( txfee == 0 ) txfee = 10000; - mofnpk = GetUnspendable(cp,0); + Heirpk = GetUnspendable(cp,0); mypk = pubkey2pk(Mypubkey()); - if ( (inputs= AddMofNInputs(cp,mtx,mofnpk,nValue+txfee,60)) > 0 ) + if ( (inputs= AddHeirInputs(cp,mtx,Heirpk,nValue+txfee,60)) > 0 ) { if ( inputs > nValue ) CCchange = (inputs - nValue - txfee); if ( CCchange != 0 ) - mtx.vout.push_back(MakeCC1vout(EVAL_MOFN,CCchange,mofnpk)); + mtx.vout.push_back(MakeCC1vout(EVAL_HEIR,CCchange,Heirpk)); mtx.vout.push_back(CTxOut(nValue,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); fprintf(stderr,"start at %u\n",(uint32_t)time(NULL)); j = rand() & 0xfffffff; for (i=0; i<1000000; i++,j++) { tmpmtx = mtx; - rawhex = FinalizeCCTx(-1LL,cp,tmpmtx,mypk,txfee,CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)EVAL_MOFN << (uint8_t)'G' << j)); + rawhex = FinalizeCCTx(-1LL,cp,tmpmtx,mypk,txfee,CScript() << OP_RETURN << E_MARSHAL(ss << (uint8_t)EVAL_HEIR << (uint8_t)'G' << j)); if ( (len= (int32_t)rawhex.size()) > 0 && len < 65536 ) { len >>= 1; @@ -191,35 +176,35 @@ std::string MofNGet(uint64_t txfee,int64_t nValue) } fprintf(stderr,"couldnt generate valid txid %u\n",(uint32_t)time(NULL)); return(""); - } else fprintf(stderr,"cant find mofn inputs\n"); + } else fprintf(stderr,"cant find Heir inputs\n"); return(""); } -std::string MofNFund(uint64_t txfee,int64_t funds) +std::string HeirFund(uint64_t txfee,int64_t funds) { - CMutableTransaction mtx; CPubKey mypk,mofnpk; CScript opret; struct CCcontract_info *cp,C; - cp = CCinit(&C,EVAL_MOFN); + CMutableTransaction mtx; CPubKey mypk,Heirpk; CScript opret; struct CCcontract_info *cp,C; + cp = CCinit(&C,EVAL_HEIR); if ( txfee == 0 ) txfee = 10000; mypk = pubkey2pk(Mypubkey()); - mofnpk = GetUnspendable(cp,0); + Heirpk = GetUnspendable(cp,0); if ( AddNormalinputs(mtx,mypk,funds+txfee,64) > 0 ) { - mtx.vout.push_back(MakeCC1vout(EVAL_MOFN,funds,mofnpk)); + mtx.vout.push_back(MakeCC1vout(EVAL_HEIR,funds,Heirpk)); return(FinalizeCCTx(0,cp,mtx,mypk,txfee,opret)); } return(""); } -UniValue MofNInfo() +UniValue HeirInfo() { UniValue result(UniValue::VOBJ); char numstr[64]; - CMutableTransaction mtx; CPubKey mofnpk; struct CCcontract_info *cp,C; int64_t funding; + CMutableTransaction mtx; CPubKey Heirpk; struct CCcontract_info *cp,C; int64_t funding; result.push_back(Pair("result","success")); - result.push_back(Pair("name","MofN")); - cp = CCinit(&C,EVAL_MOFN); - mofnpk = GetUnspendable(cp,0); - funding = AddMofNInputs(cp,mtx,mofnpk,0,0); + result.push_back(Pair("name","Heir")); + cp = CCinit(&C,EVAL_HEIR); + Heirpk = GetUnspendable(cp,0); + funding = AddHeirInputs(cp,mtx,Heirpk,0,0); sprintf(numstr,"%.8f",(double)funding/COIN); result.push_back(Pair("funding",numstr)); return(result); diff --git a/src/rpcserver.cpp b/src/rpcserver.cpp index 393545a63..5a59543c5 100644 --- a/src/rpcserver.cpp +++ b/src/rpcserver.cpp @@ -375,8 +375,8 @@ static const CRPCCommand vRPCCommands[] = { "faucet", "faucetget", &faucetget, true }, { "faucet", "faucetaddress", &faucetaddress, true }, - /* MofN */ - { "MofN", "mofnaddress", &mofnaddress, true }, + /* Heir */ + { "heir", "heiraddress", &heiraddress, true }, /* Channels */ { "channels", "channelsaddress", &channelsaddress, true }, diff --git a/src/rpcserver.h b/src/rpcserver.h index 4778ae36b..8157260aa 100644 --- a/src/rpcserver.h +++ b/src/rpcserver.h @@ -222,7 +222,7 @@ extern UniValue tokenask(const UniValue& params, bool fHelp); extern UniValue tokencancelask(const UniValue& params, bool fHelp); extern UniValue tokenfillask(const UniValue& params, bool fHelp); extern UniValue tokenconvert(const UniValue& params, bool fHelp); -extern UniValue mofnaddress(const UniValue& params, bool fHelp); +extern UniValue heiraddress(const UniValue& params, bool fHelp); extern UniValue channelsaddress(const UniValue& params, bool fHelp); extern UniValue oraclesaddress(const UniValue& params, bool fHelp); extern UniValue oracleslist(const UniValue& params, bool fHelp); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 394ff4a35..1d3ff6a1e 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5095,17 +5095,17 @@ UniValue gatewaysaddress(const UniValue& params, bool fHelp) return(CCaddress(cp,(char *)"Gateways",pubkey)); } -UniValue mofnaddress(const UniValue& params, bool fHelp) +UniValue heiraddress(const UniValue& params, bool fHelp) { struct CCcontract_info *cp,C; std::vector pubkey; - cp = CCinit(&C,EVAL_MOFN); + cp = CCinit(&C,EVAL_HEIR); if ( fHelp || params.size() > 1 ) - throw runtime_error("mofnaddress [pubkey]\n"); + throw runtime_error("heiraddress [pubkey]\n"); if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); if ( params.size() == 1 ) pubkey = ParseHex(params[0].get_str().c_str()); - return(CCaddress(cp,(char *)"MofN",pubkey)); + return(CCaddress(cp,(char *)"Heir",pubkey)); } UniValue lottoaddress(const UniValue& params, bool fHelp) From feed1b566bed5b66f893786f5b567f02dead3d84 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 10:28:11 -1100 Subject: [PATCH 082/135] CCHeir.h --- src/cc/{CCMofN.h => CCHeir.h} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/cc/{CCMofN.h => CCHeir.h} (100%) diff --git a/src/cc/CCMofN.h b/src/cc/CCHeir.h similarity index 100% rename from src/cc/CCMofN.h rename to src/cc/CCHeir.h From 880fda004f9487b7ca227f54d2f733f3139d935e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 10 Nov 2018 11:00:23 -1100 Subject: [PATCH 083/135] Orphan at 3 --- src/cc/dice.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 4da8e2d7b..235ad6569 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -364,13 +364,14 @@ void *dicefinish(void *_ptr) { ptr->orphaned++; fprintf(stderr,"ORPHANED.%d finish txid.%s\n",ptr->orphaned,ptr->txid.GetHex().c_str()); - if ( ptr->orphaned < 10 ) + if ( ptr->orphaned < 3 ) continue; if ( ptr->rawtx.empty() == 0 ) ptr->rawtx.clear(); ptr->txid = zeroid; unstringbits(name,ptr->sbits); result = 0; + ptr->orphaned = 0; res = DiceBetFinish(ptr->funcid,entropyused,entropyvout,&result,0,name,ptr->fundingtxid,ptr->bettxid,ptr->iswin,zeroid,-2); if ( ptr->entropyused == zeroid ) { From 30a8281f2f39aad686270f1c77f7f9a1dc335fbd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 00:43:45 -1100 Subject: [PATCH 084/135] -print --- src/cc/CCutils.cpp | 2 +- src/cc/dice.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 889b6fdd4..cbd4fba7a 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -386,7 +386,7 @@ int64_t CCduration(int32_t &numblocks,uint256 txid) numblocks = 0; if ( myGetTransaction(txid,tx,hashBlock) == 0 ) { - fprintf(stderr,"CCduration cant find duration txid %s\n",uint256_str(str,txid)); + //fprintf(stderr,"CCduration cant find duration txid %s\n",uint256_str(str,txid)); return(0); } else if ( hashBlock == zeroid ) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 0a6995db1..b36482e3e 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -364,7 +364,7 @@ void *dicefinish(void *_ptr) { ptr->orphaned++; fprintf(stderr,"ORPHANED.%d finish txid.%s\n",ptr->orphaned,ptr->txid.GetHex().c_str()); - if ( ptr->orphaned < 3 ) + if ( ptr->orphaned < 4 ) continue; if ( ptr->rawtx.empty() == 0 ) ptr->rawtx.clear(); From 83040356f58745e685cf38a4d867cf52611c3264 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 00:51:34 -1100 Subject: [PATCH 085/135] Allow 1:1 betting --- src/cc/dice.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index b36482e3e..9460bcdc3 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -526,7 +526,7 @@ void DiceQueue(int32_t iswin,uint64_t sbits,uint256 fundingtxid,uint256 bettxid, ptr->winamount = betTx.vout[1].nValue * ((betTx.vout[2].nValue - txfee)+1); ptr->entropyvout = entropyvout; DL_APPEND(DICEFINISH_LIST,ptr); - fprintf(stderr,"queued iswin.%d %.8f -> %.8f %s\n",iswin,(double)betTx.vout[1].nValue/COIN,(double)ptr->winamount/COIN,bettxid.GetHex().c_str()); + fprintf(stderr,"queued %dx iswin.%d %.8f -> %.8f %s\n",(int32_t)(betTx.vout[2].nValue - txfee),iswin,(double)betTx.vout[1].nValue/COIN,(double)ptr->winamount/COIN,bettxid.GetHex().c_str()); } else { @@ -1332,7 +1332,7 @@ UniValue DiceList() std::string DiceCreateFunding(uint64_t txfee,char *planstr,int64_t funds,int64_t minbet,int64_t maxbet,int64_t maxodds,int64_t timeoutblocks) { CMutableTransaction mtx; uint256 zero; CScript fundingPubKey; CPubKey mypk,dicepk; int64_t a,b,c,d; uint64_t sbits; struct CCcontract_info *cp,C; - if ( funds < 0 || minbet < 0 || maxbet < 0 || maxodds < 2 || maxodds > 9999 || timeoutblocks < 0 || timeoutblocks > 1440 ) + if ( funds < 0 || minbet < 0 || maxbet < 0 || maxodds < 1 || maxodds > 9999 || timeoutblocks < 0 || timeoutblocks > 1440 ) { CCerror = "invalid parameter error"; fprintf(stderr,"%s\n", CCerror.c_str() ); @@ -1416,7 +1416,7 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet CCerror = "bet must be positive"; return(""); } - if ( odds < 2 || odds > 9999 ) + if ( odds < 1 || odds > 9999 ) { CCerror = "odds must be between 2 and 9999"; return(""); From 955d299551c8fbf8dc1e45cbe586815684564d16 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 01:15:34 -1100 Subject: [PATCH 086/135] HASH_TABLE for betted --- src/cc/dice.cpp | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 9460bcdc3..4109cedc3 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -102,14 +102,13 @@ What is needed is for the dealer node to track the entropy tx that was already b extern int32_t KOMODO_INSYNC; -static uint256 bettxids[MAX_ENTROPYUSED],Entropyused[MAX_ENTROPYUSED][2]; // change to hashtable +//static uint256 bettxids[MAX_ENTROPYUSED]; +static uint256 Entropyused[MAX_ENTROPYUSED][2]; // change to hashtable static CTransaction betTxs[MAX_ENTROPYUSED]; static int32_t entropyvouts[MAX_ENTROPYUSED]; pthread_mutex_t DICE_MUTEX,DICEREVEALED_MUTEX; -struct dicefinish_utxo { uint256 txid; int32_t vout; }; - struct dicefinish_info { struct dicefinish_info *prev,*next; @@ -123,37 +122,61 @@ struct dicefinish_info uint8_t funcid; } *DICEFINISH_LIST; +struct dicehash_entry +{ + UT_hash_handle hh; + uint256 bettxid; +} *DICEHASH_TABLE; + int32_t _dicehash_find(uint256 bettxid) { - int32_t i; + struct dicehash_entry *ptr; + HASH_FIND(hh,DICEHASH_TABLE,&bettxid,sizeof(bettxid),ptr); + if ( ptr != 0 ) + { + fprintf(stderr,"hash_find %s got %s\n",bettxid.GetHex().c_str(),ptr->bettxid.GetHex().c_str()); + return(1); + } + return(0); + /*int32_t i; for (i=0; i Date: Sun, 11 Nov 2018 01:16:52 -1100 Subject: [PATCH 087/135] struct dicefinish_utxo { uint256 txid; int32_t vout; }; --- src/cc/dice.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 4109cedc3..13d9156d3 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -109,6 +109,8 @@ static int32_t entropyvouts[MAX_ENTROPYUSED]; pthread_mutex_t DICE_MUTEX,DICEREVEALED_MUTEX; +struct dicefinish_utxo { uint256 txid; int32_t vout; }; + struct dicefinish_info { struct dicefinish_info *prev,*next; From 5240f2793f91d518ebedca268277806767da076c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 01:19:32 -1100 Subject: [PATCH 088/135] struct dicehash_entry * --- src/cc/dice.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 13d9156d3..fa229bd48 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -168,8 +168,9 @@ int32_t _dicehash_clear(uint256 bettxid) return(0);*/ } -void _dicehash_add(uint256 bettxid) +struct dicehash_entry *_dicehash_add(uint256 bettxid) { + struct dicehash_entry *ptr; /*int32_t i; for (i=0; i Date: Sun, 11 Nov 2018 01:23:27 -1100 Subject: [PATCH 089/135] Test --- src/cc/dice.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index fa229bd48..a02d3e5b8 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -171,6 +171,8 @@ int32_t _dicehash_clear(uint256 bettxid) struct dicehash_entry *_dicehash_add(uint256 bettxid) { struct dicehash_entry *ptr; + ptr = (struct dicehash_entry *)calloc(1,sizeof(*ptr)); + ptr->bettxid = bettxid; /*int32_t i; for (i=0; i Date: Sun, 11 Nov 2018 01:40:21 -1100 Subject: [PATCH 090/135] Entropy hash table --- src/cc/dice.cpp | 84 ++++++++++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 36 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index a02d3e5b8..748811a04 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -102,10 +102,9 @@ What is needed is for the dealer node to track the entropy tx that was already b extern int32_t KOMODO_INSYNC; -//static uint256 bettxids[MAX_ENTROPYUSED]; -static uint256 Entropyused[MAX_ENTROPYUSED][2]; // change to hashtable -static CTransaction betTxs[MAX_ENTROPYUSED]; -static int32_t entropyvouts[MAX_ENTROPYUSED]; +//static uint256 Entropyused[MAX_ENTROPYUSED][2]; // change to hashtable +//static CTransaction betTxs[MAX_ENTROPYUSED]; +//static int32_t entropyvouts[MAX_ENTROPYUSED]; pthread_mutex_t DICE_MUTEX,DICEREVEALED_MUTEX; @@ -130,21 +129,19 @@ struct dicehash_entry uint256 bettxid; } *DICEHASH_TABLE; -int32_t _dicehash_find(uint256 bettxid) +struct dice_entropy +{ + UT_hash_handle hh; + uint256 entropyused,bettxid; + CTransaction betTx; + int32_t entropyvout; +} *DICE_ENTROPY; + +struct dicehash_entry *_dicehash_find(uint256 bettxid) { struct dicehash_entry *ptr; HASH_FIND(hh,DICEHASH_TABLE,&bettxid,sizeof(bettxid),ptr); - if ( ptr != 0 ) - { - fprintf(stderr,"hash_find %s got %s\n",bettxid.GetHex().c_str(),ptr->bettxid.GetHex().c_str()); - return(1); - } - return(0); - /*int32_t i; - for (i=0; ibettxid = bettxid; - /*int32_t i; - for (i=0; ientropyvout ) + { + if ( bettxid == ptr->bettxid ) + { + fprintf(stderr,"identical %s E.%s v.%d\n",bettxid.GetHex().c_str(),entropyused.GetHex().c_str(),entropyvout); + return(entropyvout+1); + } + else + { + fprintf(stderr,"found identical entropy used.%s %s vs %s v.%d vs %d\n",entropyused.GetHex().c_str(),bettxid.GetHex().c_str(),ptr->bettxid.GetHex().c_str(),entropyvout,ptr->entropyvout); + oldbettxid = ptr->bettxid; + oldbetTx = ptr->betTx; + oldentropyvout = ptr->entropyvout; + return(-1); + } + } else fprintf(stderr,"shared entropy.%s vouts %d vs %d\n",entropyused.GetHex().c_str(),entropyvout,entropyvouts[i]); + } + return(0); + /*int32_t i; for (i=0; ientropyused = entropyused; + ptr->bettxid = bettxid; + ptr->betTx = betTx; + ptr->entropyvout = entropyvout; + HASH_ADD(hh,DICE_ENTROPY,entropyused,sizeof(entropyused),ptr); + return(ptr); +/* int32_t i; for (i=0; i Date: Sun, 11 Nov 2018 01:41:18 -1100 Subject: [PATCH 091/135] Fix --- src/cc/dice.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 748811a04..fe42620c9 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -168,7 +168,7 @@ struct dicehash_entry *_dicehash_add(uint256 bettxid) int32_t _dicerevealed_find(uint256 &oldbettxid,CTransaction &oldbetTx,int32_t &oldentropyvout,uint256 entropyused,uint256 bettxid,int32_t entropyvout) { - struct dicehash_entry *ptr; + struct dice_entropy *ptr; HASH_FIND(hh,DICE_ENTROPY,&entropyused,sizeof(entropyused),ptr); if ( ptr != 0 ) { @@ -187,7 +187,7 @@ int32_t _dicerevealed_find(uint256 &oldbettxid,CTransaction &oldbetTx,int32_t &o oldentropyvout = ptr->entropyvout; return(-1); } - } else fprintf(stderr,"shared entropy.%s vouts %d vs %d\n",entropyused.GetHex().c_str(),entropyvout,entropyvouts[i]); + } else fprintf(stderr,"shared entropy.%s vouts %d vs %d\n",entropyused.GetHex().c_str(),entropyvout,ptr->entropyvout); } return(0); /*int32_t i; From 31bcb93378767902f2adc65096ba2ed94e430298 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 01:47:51 -1100 Subject: [PATCH 092/135] Entropy hash table --- src/cc/dice.cpp | 38 +------------------------------------- 1 file changed, 1 insertion(+), 37 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index fe42620c9..e925ba3dd 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -101,11 +101,6 @@ What is needed is for the dealer node to track the entropy tx that was already b #define DICE_MINUTXOS 7777 extern int32_t KOMODO_INSYNC; - -//static uint256 Entropyused[MAX_ENTROPYUSED][2]; // change to hashtable -//static CTransaction betTxs[MAX_ENTROPYUSED]; -//static int32_t entropyvouts[MAX_ENTROPYUSED]; - pthread_mutex_t DICE_MUTEX,DICEREVEALED_MUTEX; struct dicefinish_utxo { uint256 txid; int32_t vout; }; @@ -176,7 +171,7 @@ int32_t _dicerevealed_find(uint256 &oldbettxid,CTransaction &oldbetTx,int32_t &o { if ( bettxid == ptr->bettxid ) { - fprintf(stderr,"identical %s E.%s v.%d\n",bettxid.GetHex().c_str(),entropyused.GetHex().c_str(),entropyvout); + //fprintf(stderr,"identical %s E.%s v.%d\n",bettxid.GetHex().c_str(),entropyused.GetHex().c_str(),entropyvout); return(entropyvout+1); } else @@ -190,24 +185,6 @@ int32_t _dicerevealed_find(uint256 &oldbettxid,CTransaction &oldbetTx,int32_t &o } else fprintf(stderr,"shared entropy.%s vouts %d vs %d\n",entropyused.GetHex().c_str(),entropyvout,ptr->entropyvout); } return(0); - /*int32_t i; - for (i=0; ientropyvout = entropyvout; HASH_ADD(hh,DICE_ENTROPY,entropyused,sizeof(entropyused),ptr); return(ptr); -/* - int32_t i; - for (i=0; i Date: Sun, 11 Nov 2018 02:44:10 -1100 Subject: [PATCH 093/135] Tweak orphan handling --- src/cc/dice.cpp | 2 +- src/cc/heir.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index e925ba3dd..c97d7111b 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -357,7 +357,7 @@ void *dicefinish(void *_ptr) else if ( mytxid_inmempool(ptr->bettxid) != 0 ) ptr->bettxid_ready = (uint32_t)time(NULL); } - else if ( newblock != 0 && myGetTransaction(ptr->bettxid,betTx,hashBlock) == 0 ) + else if ( newblock != 0 && (myGetTransaction(ptr->bettxid,betTx,hashBlock) == 0 || now > ptr->bettxid_ready+600) ) { fprintf(stderr,"ORPHANED bettxid.%s\n",ptr->bettxid.GetHex().c_str()); dicefinish_delete(ptr); diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index d4aab932a..c3e7d03e1 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -16,7 +16,8 @@ #include "CCHeir.h" /* - The idea of Heir CC is to allow crypto inheritance + The idea of Heir CC is to allow crypto inheritance. + A special 1of2 CC address is created that is freely spendable by the creator. The heir is only allowed to spend after the specified amount of idle blocks. The idea is that if the address doesnt spend any funds for a year (or whatever amount set), then it is time to allow the heir to spend. The design requires the heir to spend all the funds at once */ // start of consensus code From 84fff7e0972995b5f56792dbf521bef21ef77b28 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 03:47:06 -1100 Subject: [PATCH 094/135] Disable odds 1 as it is broken --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index c97d7111b..ced82a4eb 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1421,7 +1421,7 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet CCerror = "bet must be positive"; return(""); } - if ( odds < 1 || odds > 9999 ) + if ( odds < 2 || odds > 9999 ) { CCerror = "odds must be between 2 and 9999"; return(""); From 34b1a40307c0202ac0ac4c41f8a4b91ebbb57405 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 04:38:29 -1100 Subject: [PATCH 095/135] Remove longest chain mutex --- src/rpcnet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp index 97bf5001d..cf76ac9d3 100644 --- a/src/rpcnet.cpp +++ b/src/rpcnet.cpp @@ -171,7 +171,7 @@ int32_t komodo_longestchain() int32_t ht,n=0,num=0,maxheight=0,height = 0; vector vstats; { - LOCK(cs_main); + //LOCK(cs_main); CopyNodeStats(vstats); } BOOST_FOREACH(const CNodeStats& stats, vstats) From 58b0fc23ace899f702bf5e9bcabf81ca186d0c66 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 05:06:36 -1100 Subject: [PATCH 096/135] Guard longest chain and GetNodeStateStats --- src/main.cpp | 33 ++++++++++++++-------- src/rpcnet.cpp | 76 ++++++++++++++++++++++++++++---------------------- 2 files changed, 64 insertions(+), 45 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 64d48d7ae..bc371e4eb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -532,17 +532,28 @@ namespace { } // anon namespace -bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats) { - LOCK(cs_main); - CNodeState *state = State(nodeid); - if (state == NULL) - return false; - stats.nMisbehavior = state->nMisbehavior; - stats.nSyncHeight = state->pindexBestKnownBlock ? state->pindexBestKnownBlock->nHeight : -1; - stats.nCommonHeight = state->pindexLastCommonBlock ? state->pindexLastCommonBlock->nHeight : -1; - BOOST_FOREACH(const QueuedBlock& queue, state->vBlocksInFlight) { - if (queue.pindex) - stats.vHeightInFlight.push_back(queue.pindex->nHeight); +bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats) +{ + static int32_t depth; + if ( depth < 0 ) + depth = 0; + if ( depth == 0 ) + { + LOCK(cs_main); + CNodeState *state = State(nodeid); + if (state == NULL) + { + depth--; + return false; + } + stats.nMisbehavior = state->nMisbehavior; + stats.nSyncHeight = state->pindexBestKnownBlock ? state->pindexBestKnownBlock->nHeight : -1; + stats.nCommonHeight = state->pindexLastCommonBlock ? state->pindexLastCommonBlock->nHeight : -1; + BOOST_FOREACH(const QueuedBlock& queue, state->vBlocksInFlight) { + if (queue.pindex) + stats.vHeightInFlight.push_back(queue.pindex->nHeight); + } + depth--; } return true; } diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp index cf76ac9d3..3dcf52b59 100644 --- a/src/rpcnet.cpp +++ b/src/rpcnet.cpp @@ -168,43 +168,51 @@ UniValue getpeerinfo(const UniValue& params, bool fHelp) int32_t KOMODO_LONGESTCHAIN; int32_t komodo_longestchain() { + static int32_t depth; int32_t ht,n=0,num=0,maxheight=0,height = 0; - vector vstats; + if ( depth < 0 ) + depth = 0; + if ( depth == 0 ) { - //LOCK(cs_main); - CopyNodeStats(vstats); + depth++; + vector vstats; + { + //LOCK(cs_main); + CopyNodeStats(vstats); + } + BOOST_FOREACH(const CNodeStats& stats, vstats) + { + //fprintf(stderr,"komodo_longestchain iter.%d\n",n); + CNodeStateStats statestats; + bool fStateStats = GetNodeStateStats(stats.nodeid,statestats); + if ( statestats.nSyncHeight < 0 ) + continue; + ht = 0; + if ( stats.nStartingHeight > ht ) + ht = stats.nStartingHeight; + if ( statestats.nSyncHeight > ht ) + ht = statestats.nSyncHeight; + if ( statestats.nCommonHeight > ht ) + ht = statestats.nCommonHeight; + if ( maxheight == 0 || ht > maxheight*1.01 ) + maxheight = ht, num = 1; + else if ( ht > maxheight*0.99 ) + num++; + if ( ht > height ) + height = ht; + } + depth--; + if ( num > (n >> 1) ) + { + extern char ASSETCHAINS_SYMBOL[]; + if ( 0 && height != KOMODO_LONGESTCHAIN ) + fprintf(stderr,"set %s KOMODO_LONGESTCHAIN <- %d\n",ASSETCHAINS_SYMBOL,height); + KOMODO_LONGESTCHAIN = height; + return(height); + } + KOMODO_LONGESTCHAIN = 0; } - BOOST_FOREACH(const CNodeStats& stats, vstats) - { - //fprintf(stderr,"komodo_longestchain iter.%d\n",n); - CNodeStateStats statestats; - bool fStateStats = GetNodeStateStats(stats.nodeid,statestats); - if ( statestats.nSyncHeight < 0 ) - continue; - ht = 0; - if ( stats.nStartingHeight > ht ) - ht = stats.nStartingHeight; - if ( statestats.nSyncHeight > ht ) - ht = statestats.nSyncHeight; - if ( statestats.nCommonHeight > ht ) - ht = statestats.nCommonHeight; - if ( maxheight == 0 || ht > maxheight*1.01 ) - maxheight = ht, num = 1; - else if ( ht > maxheight*0.99 ) - num++; - if ( ht > height ) - height = ht; - } - if ( num > (n >> 1) ) - { - extern char ASSETCHAINS_SYMBOL[]; - if ( 0 && height != KOMODO_LONGESTCHAIN ) - fprintf(stderr,"set %s KOMODO_LONGESTCHAIN <- %d\n",ASSETCHAINS_SYMBOL,height); - KOMODO_LONGESTCHAIN = height; - return(height); - } - KOMODO_LONGESTCHAIN = 0; - return(0); + return(KOMODO_LONGESTCHAIN); } UniValue addnode(const UniValue& params, bool fHelp) From f7dc8fe3e7b27ed8606ea19a6439dfbc0b373318 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 05:15:27 -1100 Subject: [PATCH 097/135] Skip longest chain call, since it is in connect tip --- src/komodo_gateway.h | 2 +- src/rpcblockchain.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 400ded593..96d4ea121 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1382,7 +1382,7 @@ void komodo_passport_iteration() { if ( ASSETCHAINS_SYMBOL[0] == 0 ) komodo_interestsum(); - komodo_longestchain(); + //komodo_longestchain(); lastinterest = komodo_chainactive_timestamp(); } refsp = komodo_stateptr(symbol,dest); diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 868431f6f..91cd82303 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -33,6 +33,7 @@ extern void TxToJSON(const CTransaction& tx, const uint256 hashBlock, UniValue& void ScriptPubKeyToJSON(const CScript& scriptPubKey, UniValue& out, bool fIncludeHex); int32_t komodo_longestchain(); int32_t komodo_dpowconfs(int32_t height,int32_t numconfs); +extern int32_t KOMODO_LONGESTCHAIN; double GetDifficultyINTERNAL(const CBlockIndex* blockindex, bool networkDifficulty) { @@ -1327,7 +1328,7 @@ UniValue getblockchaininfo(const UniValue& params, bool fHelp) if ( ASSETCHAINS_SYMBOL[0] == 0 ) { progress = Checkpoints::GuessVerificationProgress(Params().Checkpoints(), chainActive.LastTip()); } else { - int32_t longestchain = komodo_longestchain(); + int32_t longestchain = KOMODO_LONGESTCHAIN;//komodo_longestchain(); progress = (longestchain > 0 ) ? (double) chainActive.Height() / longestchain : 1.0; } UniValue obj(UniValue::VOBJ); From 47538c0995747c5a03f5484205b68d48df31982b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 05:27:38 -1100 Subject: [PATCH 098/135] Revert depth guard --- src/main.cpp | 33 +++++++++++---------------------- 1 file changed, 11 insertions(+), 22 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index bc371e4eb..64d48d7ae 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -532,28 +532,17 @@ namespace { } // anon namespace -bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats) -{ - static int32_t depth; - if ( depth < 0 ) - depth = 0; - if ( depth == 0 ) - { - LOCK(cs_main); - CNodeState *state = State(nodeid); - if (state == NULL) - { - depth--; - return false; - } - stats.nMisbehavior = state->nMisbehavior; - stats.nSyncHeight = state->pindexBestKnownBlock ? state->pindexBestKnownBlock->nHeight : -1; - stats.nCommonHeight = state->pindexLastCommonBlock ? state->pindexLastCommonBlock->nHeight : -1; - BOOST_FOREACH(const QueuedBlock& queue, state->vBlocksInFlight) { - if (queue.pindex) - stats.vHeightInFlight.push_back(queue.pindex->nHeight); - } - depth--; +bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats) { + LOCK(cs_main); + CNodeState *state = State(nodeid); + if (state == NULL) + return false; + stats.nMisbehavior = state->nMisbehavior; + stats.nSyncHeight = state->pindexBestKnownBlock ? state->pindexBestKnownBlock->nHeight : -1; + stats.nCommonHeight = state->pindexLastCommonBlock ? state->pindexLastCommonBlock->nHeight : -1; + BOOST_FOREACH(const QueuedBlock& queue, state->vBlocksInFlight) { + if (queue.pindex) + stats.vHeightInFlight.push_back(queue.pindex->nHeight); } return true; } From f1c84619bfb283290df891662951bd2425f120a9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 05:35:42 -1100 Subject: [PATCH 099/135] increase number of 0.0002 utxos --- src/cc/dice.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index ced82a4eb..4ad9146b5 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -319,7 +319,7 @@ void dicefinish_delete(struct dicefinish_info *ptr) void *dicefinish(void *_ptr) { - std::vector mypk; struct CCcontract_info *cp,C; char name[32],coinaddr[64],CCaddr[64]; std::string res; int32_t newht,newblock,entropyvout,numblocks,lastheight=0,vin0_needed,n,m,num,iter,result; struct dicefinish_info *ptr,*tmp; uint32_t now; struct dicefinish_utxo *utxos; uint256 hashBlock,entropyused; CTransaction betTx,finishTx; + std::vector mypk; struct CCcontract_info *cp,C; char name[32],coinaddr[64],CCaddr[64]; std::string res; int32_t newht,newblock,entropyvout,numblocks,lastheight=0,vin0_needed,i,n,m,num,iter,result; struct dicefinish_info *ptr,*tmp; uint32_t now; struct dicefinish_utxo *utxos; uint256 hashBlock,entropyused; CTransaction betTx,finishTx; mypk = Mypubkey(); pubkey2addr(coinaddr,mypk.data()); cp = CCinit(&C,EVAL_DICE); @@ -478,9 +478,13 @@ void *dicefinish(void *_ptr) { char *cmd = (char *)malloc(100 * 128); sprintf(cmd,"./komodo-cli -ac_name=%s sendmany \"\" \"{\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002}\"",ASSETCHAINS_SYMBOL,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr); - fprintf(stderr,"num normal 0.0002 utxos.%d < %d\n",num,DICE_MINUTXOS); - if ( system(cmd) != 0 ) - fprintf(stderr,"system error issuing.(%s)\n",cmd); + n = sqrt((DICE_MINUTXOS - num) / 100) + 1; + fprintf(stderr,"num normal 0.0002 utxos.%d < %d -> n.%d\n",num,DICE_MINUTXOS); + for (i=0; i Date: Sun, 11 Nov 2018 05:36:32 -1100 Subject: [PATCH 100/135] N --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 4ad9146b5..8aee316f8 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -479,7 +479,7 @@ void *dicefinish(void *_ptr) char *cmd = (char *)malloc(100 * 128); sprintf(cmd,"./komodo-cli -ac_name=%s sendmany \"\" \"{\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002}\"",ASSETCHAINS_SYMBOL,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr); n = sqrt((DICE_MINUTXOS - num) / 100) + 1; - fprintf(stderr,"num normal 0.0002 utxos.%d < %d -> n.%d\n",num,DICE_MINUTXOS); + fprintf(stderr,"num normal 0.0002 utxos.%d < %d -> n.%d\n",num,DICE_MINUTXOS,n); for (i=0; i Date: Sun, 11 Nov 2018 06:04:19 -1100 Subject: [PATCH 101/135] Sqrt limit for entropy --- src/cc/dice.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 8aee316f8..62dffb7f7 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1708,7 +1708,8 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx DicePlanFunds(entropyval,entropytxid,refsbits,cp,dicepk,fundingtxid,entropytxs,false); if ( entropytxs < DICE_MINUTXOS ) { - for (i=0; i 64 && is_hexstr((char *)res.c_str(),0) > 64 ) @@ -1718,7 +1719,7 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx //LOCK(cs_main); if ( myAddtomempool(tx) != 0 ) { - fprintf(stderr,"ENTROPY %s: %d of %d\n",tx.GetHash().GetHex().c_str(),i,DICE_MINUTXOS - entropytxs); + fprintf(stderr,"ENTROPY %s: %d of %d, %d\n",tx.GetHash().GetHex().c_str(),i,n,DICE_MINUTXOS - entropytxs); RelayTransaction(tx); } else break; } else break; From ff905c4fa719cca5642a4cf4d7769c23c1d29d33 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 06:32:39 -1100 Subject: [PATCH 102/135] Double vins --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 62dffb7f7..5234dd162 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -478,7 +478,7 @@ void *dicefinish(void *_ptr) { char *cmd = (char *)malloc(100 * 128); sprintf(cmd,"./komodo-cli -ac_name=%s sendmany \"\" \"{\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002}\"",ASSETCHAINS_SYMBOL,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr); - n = sqrt((DICE_MINUTXOS - num) / 100) + 1; + n = sqrt((DICE_MINUTXOS - num) / 100)*2 + 1; fprintf(stderr,"num normal 0.0002 utxos.%d < %d -> n.%d\n",num,DICE_MINUTXOS,n); for (i=0; i Date: Sun, 11 Nov 2018 06:53:30 -1100 Subject: [PATCH 103/135] Dont call longest chain in background loop --- src/bitcoind.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index f05b522fa..80fef2c0f 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -63,7 +63,7 @@ void WaitForShutdown(boost::thread_group* threadGroup) else { //komodo_interestsum(); - komodo_longestchain(); + //komodo_longestchain(); MilliSleep(20000); } fShutdown = ShutdownRequested(); From 818165d7a3ccba7ab8741e6ea5e2f52bd5d2c670 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 07:09:17 -1100 Subject: [PATCH 104/135] Test --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 5234dd162..0602c78d4 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -478,7 +478,7 @@ void *dicefinish(void *_ptr) { char *cmd = (char *)malloc(100 * 128); sprintf(cmd,"./komodo-cli -ac_name=%s sendmany \"\" \"{\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002}\"",ASSETCHAINS_SYMBOL,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr); - n = sqrt((DICE_MINUTXOS - num) / 100)*2 + 1; + n = 1;//sqrt((DICE_MINUTXOS - num) / 100)*2 + 1; fprintf(stderr,"num normal 0.0002 utxos.%d < %d -> n.%d\n",num,DICE_MINUTXOS,n); for (i=0; i Date: Sun, 11 Nov 2018 07:13:41 -1100 Subject: [PATCH 105/135] Test --- src/cc/dice.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 0602c78d4..0f96228e2 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -478,7 +478,7 @@ void *dicefinish(void *_ptr) { char *cmd = (char *)malloc(100 * 128); sprintf(cmd,"./komodo-cli -ac_name=%s sendmany \"\" \"{\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002}\"",ASSETCHAINS_SYMBOL,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr); - n = 1;//sqrt((DICE_MINUTXOS - num) / 100)*2 + 1; + n = sqrt((DICE_MINUTXOS - num) / 100)*2 + 1; fprintf(stderr,"num normal 0.0002 utxos.%d < %d -> n.%d\n",num,DICE_MINUTXOS,n); for (i=0; i Date: Sun, 11 Nov 2018 08:10:17 -1100 Subject: [PATCH 106/135] Move entropy tx into dice finish --- src/cc/CCdice.h | 1 + src/cc/dice.cpp | 34 ++++++++++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/cc/CCdice.h b/src/cc/CCdice.h index 8c67d86fe..4a526bfcf 100644 --- a/src/cc/CCdice.h +++ b/src/cc/CCdice.h @@ -30,5 +30,6 @@ std::string DiceCreateFunding(uint64_t txfee,char *planstr,int64_t funds,int64_t std::string DiceAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t amount); UniValue DiceInfo(uint256 diceid); UniValue DiceList(); +int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbits,struct CCcontract_info *cp,CPubKey dicepk,uint256 reffundingtxid, int32_t &entropytxs,bool random); #endif diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 0f96228e2..e589ea51c 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -319,10 +319,11 @@ void dicefinish_delete(struct dicefinish_info *ptr) void *dicefinish(void *_ptr) { - std::vector mypk; struct CCcontract_info *cp,C; char name[32],coinaddr[64],CCaddr[64]; std::string res; int32_t newht,newblock,entropyvout,numblocks,lastheight=0,vin0_needed,i,n,m,num,iter,result; struct dicefinish_info *ptr,*tmp; uint32_t now; struct dicefinish_utxo *utxos; uint256 hashBlock,entropyused; CTransaction betTx,finishTx; + std::vector mypk; struct CCcontract_info *cp,C; char name[32],coinaddr[64],CCaddr[64]; std::string res; int32_t newht,newblock,entropyvout,numblocks,lastheight=0,vin0_needed,i,n,m,num,iter,result; struct dicefinish_info *ptr,*tmp; uint32_t now; struct dicefinish_utxo *utxos; uint256 hashBlock,entropyused; CPubkey dicepk; CTransaction betTx,finishTx,tx; mypk = Mypubkey(); pubkey2addr(coinaddr,mypk.data()); cp = CCinit(&C,EVAL_DICE); + dicepk = GetUnspendable(cp,0); GetCCaddress(cp,CCaddr,GetUnspendable(cp,0)); fprintf(stderr,"start dicefinish thread %s CCaddr.%s\n",coinaddr,CCaddr); if ( (newht= KOMODO_INSYNC) == 0 ) @@ -493,6 +494,35 @@ void *dicefinish(void *_ptr) fprintf(stderr,"system error issuing.(cc/dapps/sendmany)\n"); } } + if ( newblock != 0 ) + { + CTransaction tx; uint64_t entropyval; uint64_t sbits; uint256 fundingtxid,entropytxid; int32_t entropytxs; uint8_t pubkey33[33]; + decode_hex(pubkey33,33,"0354ad90c26923962bbdfc7fd4956cb52db73682b58df9ee3ffc4751e61c8d465d"); + if ( memcmp(pubkey33,mypk.data(),33) == 0 ) + { + fundingtxid = uint256S("0x5be49570c56d036abb08b6d084da93a8a86f58fc48db4a1086be95540d752d6f"); + sbits = stringbits((char *)"KMDICE"); + fprintf(stderr,"do the entropy tx\n"); + DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,fundingtxid,entropytxs,false); + if ( entropytxs < DICE_MINUTXOS ) + { + n = sqrt(DICE_MINUTXOS - entropytxs); + res = DiceAddfunding(10000,planstr,fundingtxid,COIN/100); + if ( res.empty() == 0 && res.size() > 64 && is_hexstr((char *)res.c_str(),0) > 64 ) + { + if ( DecodeHexTx(tx,res) != 0 ) + { + //LOCK(cs_main); + if ( myAddtomempool(tx) != 0 ) + { + fprintf(stderr,"ENTROPY %s: %d of %d, %d\n",tx.GetHash().GetHex().c_str(),i,n,DICE_MINUTXOS - entropytxs); + RelayTransaction(tx); + } else break; + } else break; + } else break; + } + } + } } } if ( (newht= KOMODO_INSYNC) == 0 || newht == lastheight ) @@ -1702,7 +1732,7 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx } } } - if ( scriptPubKey == fundingPubKey ) + if ( 0 && scriptPubKey == fundingPubKey ) { CTransaction tx; uint64_t entropyval; uint256 entropytxid; int32_t entropytxs; DicePlanFunds(entropyval,entropytxid,refsbits,cp,dicepk,fundingtxid,entropytxs,false); From ad4b57602eed10d4c0899ec42ed993a453bad109 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 08:11:58 -1100 Subject: [PATCH 107/135] Test --- src/cc/dice.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index e589ea51c..2333f99c7 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -319,7 +319,7 @@ void dicefinish_delete(struct dicefinish_info *ptr) void *dicefinish(void *_ptr) { - std::vector mypk; struct CCcontract_info *cp,C; char name[32],coinaddr[64],CCaddr[64]; std::string res; int32_t newht,newblock,entropyvout,numblocks,lastheight=0,vin0_needed,i,n,m,num,iter,result; struct dicefinish_info *ptr,*tmp; uint32_t now; struct dicefinish_utxo *utxos; uint256 hashBlock,entropyused; CPubkey dicepk; CTransaction betTx,finishTx,tx; + std::vector mypk; struct CCcontract_info *cp,C; char name[32],coinaddr[64],CCaddr[64]; std::string res; int32_t newht,newblock,entropyvout,numblocks,lastheight=0,vin0_needed,i,n,m,num,iter,result; struct dicefinish_info *ptr,*tmp; uint32_t now; struct dicefinish_utxo *utxos; uint256 hashBlock,entropyused; CPubKey dicepk; CTransaction betTx,finishTx,tx; mypk = Mypubkey(); pubkey2addr(coinaddr,mypk.data()); cp = CCinit(&C,EVAL_DICE); @@ -496,12 +496,12 @@ void *dicefinish(void *_ptr) } if ( newblock != 0 ) { - CTransaction tx; uint64_t entropyval; uint64_t sbits; uint256 fundingtxid,entropytxid; int32_t entropytxs; uint8_t pubkey33[33]; + CTransaction tx; uint64_t entropyval; uint64_t sbits; uint256 fundingtxid,entropytxid; int32_t entropytxs; uint8_t pubkey33[33]; char *planstr = (char *)"KMDICE"; decode_hex(pubkey33,33,"0354ad90c26923962bbdfc7fd4956cb52db73682b58df9ee3ffc4751e61c8d465d"); if ( memcmp(pubkey33,mypk.data(),33) == 0 ) { fundingtxid = uint256S("0x5be49570c56d036abb08b6d084da93a8a86f58fc48db4a1086be95540d752d6f"); - sbits = stringbits((char *)"KMDICE"); + sbits = stringbits(planstr); fprintf(stderr,"do the entropy tx\n"); DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,fundingtxid,entropytxs,false); if ( entropytxs < DICE_MINUTXOS ) From 2a2b782298e504ec4cb11b071ea5f53127906b62 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 08:13:42 -1100 Subject: [PATCH 108/135] Test --- src/cc/dice.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 2333f99c7..91d088eb8 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -497,10 +497,10 @@ void *dicefinish(void *_ptr) if ( newblock != 0 ) { CTransaction tx; uint64_t entropyval; uint64_t sbits; uint256 fundingtxid,entropytxid; int32_t entropytxs; uint8_t pubkey33[33]; char *planstr = (char *)"KMDICE"; - decode_hex(pubkey33,33,"0354ad90c26923962bbdfc7fd4956cb52db73682b58df9ee3ffc4751e61c8d465d"); + decode_hex(pubkey33,33,(char *)"0354ad90c26923962bbdfc7fd4956cb52db73682b58df9ee3ffc4751e61c8d465d"); if ( memcmp(pubkey33,mypk.data(),33) == 0 ) { - fundingtxid = uint256S("0x5be49570c56d036abb08b6d084da93a8a86f58fc48db4a1086be95540d752d6f"); + fundingtxid = uint256S((char *)"0x5be49570c56d036abb08b6d084da93a8a86f58fc48db4a1086be95540d752d6f"); sbits = stringbits(planstr); fprintf(stderr,"do the entropy tx\n"); DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,fundingtxid,entropytxs,false); From 9c70c039f610c7c200590e9101462c785f02ba72 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 08:21:30 -1100 Subject: [PATCH 109/135] Test --- src/cc/dice.cpp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 91d088eb8..7660cd1fb 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -502,24 +502,27 @@ void *dicefinish(void *_ptr) { fundingtxid = uint256S((char *)"0x5be49570c56d036abb08b6d084da93a8a86f58fc48db4a1086be95540d752d6f"); sbits = stringbits(planstr); - fprintf(stderr,"do the entropy tx\n"); DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,fundingtxid,entropytxs,false); + fprintf(stderr,"do the entropy tx %d vs %d\n",entropytxs,DICE_MINUTXOS); if ( entropytxs < DICE_MINUTXOS ) { n = sqrt(DICE_MINUTXOS - entropytxs); - res = DiceAddfunding(10000,planstr,fundingtxid,COIN/100); - if ( res.empty() == 0 && res.size() > 64 && is_hexstr((char *)res.c_str(),0) > 64 ) + for (i=0; i 64 && is_hexstr((char *)res.c_str(),0) > 64 ) { - //LOCK(cs_main); - if ( myAddtomempool(tx) != 0 ) + if ( DecodeHexTx(tx,res) != 0 ) { - fprintf(stderr,"ENTROPY %s: %d of %d, %d\n",tx.GetHash().GetHex().c_str(),i,n,DICE_MINUTXOS - entropytxs); - RelayTransaction(tx); + //LOCK(cs_main); + if ( myAddtomempool(tx) != 0 ) + { + fprintf(stderr,"ENTROPY %s: %d of %d, %d\n",tx.GetHash().GetHex().c_str(),i,n,DICE_MINUTXOS - entropytxs); + RelayTransaction(tx); + } else break; } else break; } else break; - } else break; + } } } } From e5325b45aa83d3c66b0e1615747d6a007d316a4b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 08:31:24 -1100 Subject: [PATCH 110/135] Test --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 7660cd1fb..1a1d7377e 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -494,7 +494,7 @@ void *dicefinish(void *_ptr) fprintf(stderr,"system error issuing.(cc/dapps/sendmany)\n"); } } - if ( newblock != 0 ) + if ( 0 && newblock != 0 ) { CTransaction tx; uint64_t entropyval; uint64_t sbits; uint256 fundingtxid,entropytxid; int32_t entropytxs; uint8_t pubkey33[33]; char *planstr = (char *)"KMDICE"; decode_hex(pubkey33,33,(char *)"0354ad90c26923962bbdfc7fd4956cb52db73682b58df9ee3ffc4751e61c8d465d"); From 3424c9cb2875d7e0710f00a42e8864d6f41a69d6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 08:41:29 -1100 Subject: [PATCH 111/135] DEALER NODE --- src/cc/CCinclude.h | 2 +- src/cc/dice.cpp | 6 +++--- src/komodo_globals.h | 2 +- src/komodo_utils.h | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index 83642f020..affb57c99 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -51,7 +51,7 @@ one other technical note is that komodod has the insight-explorer extensions bui #include "../utlist.h" #include "../uthash.h" -extern int32_t KOMODO_CONNECTING,KOMODO_CCACTIVATE; +extern int32_t KOMODO_CONNECTING,KOMODO_CCACTIVATE,KOMODO_DEALERNODE; extern uint32_t ASSETCHAINS_CC; extern char ASSETCHAINS_SYMBOL[]; extern std::string CCerror; diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 1a1d7377e..7b5c6a9c3 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -975,7 +975,7 @@ bool DiceValidate(struct CCcontract_info *cp,Eval *eval,const CTransaction &tx) if ( (iswin= DiceIsWinner(entropy,entropyvout,txid,tx,vinTx,hash,sbits,minbet,maxbet,maxodds,timeoutblocks,fundingtxid)) != 0 ) { // will only happen for fundingPubKey - if ( KOMODO_INSYNC != 0 ) + if ( KOMODO_INSYNC != 0 && KOMODO_DEALERNODE != 0 ) DiceQueue(iswin,sbits,fundingtxid,txid,tx,entropyvout); } else @@ -1735,13 +1735,13 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx } } } - if ( 0 && scriptPubKey == fundingPubKey ) + if ( KOMODO_DEALERNODE == 0 && scriptPubKey == fundingPubKey ) { CTransaction tx; uint64_t entropyval; uint256 entropytxid; int32_t entropytxs; DicePlanFunds(entropyval,entropytxid,refsbits,cp,dicepk,fundingtxid,entropytxs,false); if ( entropytxs < DICE_MINUTXOS ) { - n = 10;//sqrt(DICE_MINUTXOS - entropytxs) + 10; + n = sqrt(DICE_MINUTXOS - entropytxs) + 10; for (i=0; i Date: Sun, 11 Nov 2018 08:47:55 -1100 Subject: [PATCH 112/135] Test --- src/cc/dice.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 7b5c6a9c3..42abfbffe 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1706,8 +1706,8 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx { if ( myGetTransaction(betTx.vin[0].prevout.hash,entropyTx,hashBlock) != 0 ) { - flag = 0; - if ( scriptPubKey == fundingPubKey ) + flag = KOMODO_HOUSENODE != 0; + if ( KOMODO_HOUSENODE != 0 && scriptPubKey == fundingPubKey ) { bettorentropy = DiceGetEntropy(betTx,'B'); if ( (iswin= DiceIsWinner(hentropyproof,entropyvout,txid,betTx,entropyTx,bettorentropy,sbits,minbet,maxbet,maxodds,timeoutblocks,fundingtxid)) != 0 ) From 6c339e5cdf5b795f11b10209f22670666832521b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 08:49:25 -1100 Subject: [PATCH 113/135] KOMODO_DEALERNODE --- src/cc/dice.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 42abfbffe..285c4b0c5 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1706,8 +1706,8 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx { if ( myGetTransaction(betTx.vin[0].prevout.hash,entropyTx,hashBlock) != 0 ) { - flag = KOMODO_HOUSENODE != 0; - if ( KOMODO_HOUSENODE != 0 && scriptPubKey == fundingPubKey ) + flag = KOMODO_DEALERNODE != 0; + if ( KOMODO_DEALERNODE != 0 && scriptPubKey == fundingPubKey ) { bettorentropy = DiceGetEntropy(betTx,'B'); if ( (iswin= DiceIsWinner(hentropyproof,entropyvout,txid,betTx,entropyTx,bettorentropy,sbits,minbet,maxbet,maxodds,timeoutblocks,fundingtxid)) != 0 ) From 1d95d72dcdf4ea32f79d6816d6ce35e6b3f4b6e4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 09:06:51 -1100 Subject: [PATCH 114/135] Fix --- src/cc/dice.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 285c4b0c5..a1e712b8c 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1709,6 +1709,7 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx flag = KOMODO_DEALERNODE != 0; if ( KOMODO_DEALERNODE != 0 && scriptPubKey == fundingPubKey ) { + flag = 0; bettorentropy = DiceGetEntropy(betTx,'B'); if ( (iswin= DiceIsWinner(hentropyproof,entropyvout,txid,betTx,entropyTx,bettorentropy,sbits,minbet,maxbet,maxodds,timeoutblocks,fundingtxid)) != 0 ) { @@ -1722,7 +1723,7 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx } if ( flag != 0 || scriptPubKey != fundingPubKey ) { - if ( flag != 0 ) + if ( 0 && flag != 0 ) fprintf(stderr,"illegal bettxid %d: iswin.%d W.%d L.%d %s/v%d (%c %.8f) %.8f\n",n,iswin,win,loss,txid.GetHex().c_str(),vout,funcid,(double)it->second.satoshis/COIN,(double)sum/COIN); res = DiceBetFinish(funcid,entropyused,entropyvout,&result,txfee,planstr,fundingtxid,txid,scriptPubKey == fundingPubKey,zeroid,-1); if ( result > 0 ) From de247d095cf0f2ad881cabd6f8de34f33b68b05f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 09:10:57 -1100 Subject: [PATCH 115/135] Test --- src/cc/dice.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index a1e712b8c..65f332965 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1709,7 +1709,6 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx flag = KOMODO_DEALERNODE != 0; if ( KOMODO_DEALERNODE != 0 && scriptPubKey == fundingPubKey ) { - flag = 0; bettorentropy = DiceGetEntropy(betTx,'B'); if ( (iswin= DiceIsWinner(hentropyproof,entropyvout,txid,betTx,entropyTx,bettorentropy,sbits,minbet,maxbet,maxodds,timeoutblocks,fundingtxid)) != 0 ) { @@ -1719,12 +1718,11 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx loss++; n++; DiceQueue(iswin,sbits,fundingtxid,txid,betTx,entropyvout); - } //else flag = 1; + } } - if ( flag != 0 || scriptPubKey != fundingPubKey ) + if ( KOMODO_DEALERNODE == 0 || scriptPubKey != fundingPubKey ) { - if ( 0 && flag != 0 ) - fprintf(stderr,"illegal bettxid %d: iswin.%d W.%d L.%d %s/v%d (%c %.8f) %.8f\n",n,iswin,win,loss,txid.GetHex().c_str(),vout,funcid,(double)it->second.satoshis/COIN,(double)sum/COIN); + fprintf(stderr,"serialized bettxid %d: iswin.%d W.%d L.%d %s/v%d (%c %.8f) %.8f\n",n,iswin,win,loss,txid.GetHex().c_str(),vout,funcid,(double)it->second.satoshis/COIN,(double)sum/COIN); res = DiceBetFinish(funcid,entropyused,entropyvout,&result,txfee,planstr,fundingtxid,txid,scriptPubKey == fundingPubKey,zeroid,-1); if ( result > 0 ) { From d9bb372b9a6f0ef738c65c3130bfca2a0bc2b58e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 09:11:47 -1100 Subject: [PATCH 116/135] Test --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 65f332965..46be85cfd 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1720,7 +1720,7 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx DiceQueue(iswin,sbits,fundingtxid,txid,betTx,entropyvout); } } - if ( KOMODO_DEALERNODE == 0 || scriptPubKey != fundingPubKey ) + if ( scriptPubKey != fundingPubKey ) { fprintf(stderr,"serialized bettxid %d: iswin.%d W.%d L.%d %s/v%d (%c %.8f) %.8f\n",n,iswin,win,loss,txid.GetHex().c_str(),vout,funcid,(double)it->second.satoshis/COIN,(double)sum/COIN); res = DiceBetFinish(funcid,entropyused,entropyvout,&result,txfee,planstr,fundingtxid,txid,scriptPubKey == fundingPubKey,zeroid,-1); From ac3108c8878baf52b0726b1076d379be3d9f6c58 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 09:16:28 -1100 Subject: [PATCH 117/135] +print --- src/cc/dice.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 46be85cfd..0d070ca94 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -483,6 +483,7 @@ void *dicefinish(void *_ptr) fprintf(stderr,"num normal 0.0002 utxos.%d < %d -> n.%d\n",num,DICE_MINUTXOS,n); for (i=0; i Date: Sun, 11 Nov 2018 09:21:45 -1100 Subject: [PATCH 118/135] Test --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 0d070ca94..a85ef751f 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -475,7 +475,7 @@ void *dicefinish(void *_ptr) else if ( newblock != 0 ) dicefinish_utxosget(num,0,0,coinaddr); free(utxos); - if ( newblock != 0 && num < DICE_MINUTXOS ) + if ( 0 && newblock != 0 && num < DICE_MINUTXOS ) { char *cmd = (char *)malloc(100 * 128); sprintf(cmd,"./komodo-cli -ac_name=%s sendmany \"\" \"{\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002}\"",ASSETCHAINS_SYMBOL,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr); From 9ee28e76cedd78572b20f3345cac2a6e8109293e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 09:27:12 -1100 Subject: [PATCH 119/135] Test --- src/cc/dice.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index a85ef751f..89bc1131d 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -226,7 +226,7 @@ bool mySenddicetransaction(std::string res,uint256 entropyused,int32_t entropyvo //fprintf(stderr,"%s\n%s\n",res.c_str(),uint256_str(str,tx.GetHash())); if ( funcid == 'R' || (retval= DiceEntropyUsed(oldbetTx,oldbettxid,oldentropyvout,entropyused,bettxid,betTx,entropyvout)) >= 0 ) { - //LOCK(cs_main); + LOCK(cs_main); if ( myAddtomempool(tx) != 0 ) { RelayTransaction(tx); @@ -472,7 +472,7 @@ void *dicefinish(void *_ptr) } } } - else if ( newblock != 0 ) + else if ( 0 && newblock != 0 ) dicefinish_utxosget(num,0,0,coinaddr); free(utxos); if ( 0 && newblock != 0 && num < DICE_MINUTXOS ) From 75af6fa31565dc3a101529bead0d5eaf234e657a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 09:34:01 -1100 Subject: [PATCH 120/135] Test --- src/cc/dice.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 89bc1131d..d5b11c099 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1679,7 +1679,7 @@ std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t &entropyv double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettxid) { - CScript fundingPubKey,scriptPubKey; CTransaction spenttx,betTx,entropyTx; uint256 hentropyproof,entropyused,hash,proof,txid,hashBlock,spenttxid,bettorentropy; CPubKey mypk,dicepk,fundingpk; struct CCcontract_info *cp,C; int32_t i,entropyvout,flag,win,loss,duplicate=0,result,iswin,vout,n=0; int64_t minbet,maxbet,maxodds,timeoutblocks,sum=0; uint64_t sbits,refsbits; char coinaddr[64]; std::string res; uint8_t funcid; + CScript fundingPubKey,scriptPubKey; CTransaction spenttx,betTx,entropyTx; uint256 hentropyproof,entropyused,hash,proof,txid,hashBlock,spenttxid,bettorentropy; CPubKey mypk,dicepk,fundingpk; struct CCcontract_info *cp,C; int32_t i,entropyvout,flag,win,num,loss,duplicate=0,result,iswin,vout,n=0; int64_t minbet,maxbet,maxodds,timeoutblocks,sum=0; uint64_t sbits,refsbits; char coinaddr[64]; std::string res; uint8_t funcid; if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,refsbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { CCerror = "Diceinit error in status, is your transaction confirmed?"; @@ -1759,6 +1759,27 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx } else break; } } + dicefinish_utxosget(num,0,0,coinaddr); + if ( num < DICE_MINUTXOS ) + { + char *cmd = (char *)malloc(100 * 128); + sprintf(cmd,"./komodo-cli -ac_name=%s sendmany \"\" \"{\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002}\"",ASSETCHAINS_SYMBOL,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr); + n = sqrt((DICE_MINUTXOS - num) / 100)*2 + 1; + fprintf(stderr,"num normal 0.0002 utxos.%d < %d -> n.%d\n",num,DICE_MINUTXOS,n); + for (i=0; i Date: Sun, 11 Nov 2018 09:54:58 -1100 Subject: [PATCH 121/135] Test --- src/cc/dice.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index d5b11c099..6820af2fb 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1760,7 +1760,8 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx } } dicefinish_utxosget(num,0,0,coinaddr); - if ( num < DICE_MINUTXOS ) + fprintf(stderr,"have %d 0.0002 utxos, need %d\n",num,DICE_MINUTXOS); + if ( 0 && num < DICE_MINUTXOS ) { char *cmd = (char *)malloc(100 * 128); sprintf(cmd,"./komodo-cli -ac_name=%s sendmany \"\" \"{\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002}\"",ASSETCHAINS_SYMBOL,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr); From 2e3dee15edf8dc9c74f7b19fbcca742c43ce7d29 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 09:56:11 -1100 Subject: [PATCH 122/135] Sendmany100 --- src/cc/dapps/sendmany100 | 2 ++ 1 file changed, 2 insertions(+) create mode 100755 src/cc/dapps/sendmany100 diff --git a/src/cc/dapps/sendmany100 b/src/cc/dapps/sendmany100 new file mode 100755 index 000000000..9638766ab --- /dev/null +++ b/src/cc/dapps/sendmany100 @@ -0,0 +1,2 @@ +./komodo-cli -ac_name=KMDICE sendmany "" "{\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002,\"RXgCPfi6wccRr3Eai3X9duTTkAirhcQLNo\":0.0002}" + From 59095635d73682eb8991bc8283e41bfe40d53e4c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 10:07:10 -1100 Subject: [PATCH 123/135] Prevent too many tx --- src/cc/dice.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 6820af2fb..e52d66b67 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1729,6 +1729,8 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx { mySenddicetransaction(res,entropyused,entropyvout,txid,betTx,funcid,0); n++; + if ( n > 10 ) + break; } } } else fprintf(stderr,"bettxid.%s cant find entropyTx.%s\n",txid.GetHex().c_str(),betTx.vin[0].prevout.hash.GetHex().c_str()); From 287af906d9f162b26c237a4deaf695c9c617f6b3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 10:12:35 -1100 Subject: [PATCH 124/135] Test --- src/komodo_bitcoind.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 25aa09eea..32aab3fd3 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1115,7 +1115,7 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height) if ( ASSETCHAINS_FOUNDERS != 0 ) { nSubsidy = GetBlockSubsidy(height,Params().GetConsensus()); - fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); + //fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION)); return((nSubsidy * ASSETCHAINS_COMMISSION) / COIN); n = pblock->vtx[0].vout.size(); for (j=0; j 10000 && pblock->vtx[0].vout.size() != 2 ) jl777: not sure why this was here return(-1); else*/ if ( checktoshis != 0 ) From 2e97d5bdaaff7678f4e272ba6da11258620ef9ce Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 10:54:35 -1100 Subject: [PATCH 125/135] Test --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index e52d66b67..d483a8780 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -418,7 +418,7 @@ void *dicefinish(void *_ptr) 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\n",iter,vin0_needed,n); + 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) { From 03c3f70bffebb6a62bae5850d617504279baccb4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 11:00:24 -1100 Subject: [PATCH 126/135] Fix 0,0002 display --- src/cc/dice.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index d483a8780..d2d1b426f 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1761,9 +1761,10 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx } else break; } } + pubkey2addr(coinaddr,Mypubkey().data()); dicefinish_utxosget(num,0,0,coinaddr); fprintf(stderr,"have %d 0.0002 utxos, need %d\n",num,DICE_MINUTXOS); - if ( 0 && num < DICE_MINUTXOS ) + if ( 0 && num < DICE_MINUTXOS ) // this deadlocks, need to put it in a different thread { char *cmd = (char *)malloc(100 * 128); sprintf(cmd,"./komodo-cli -ac_name=%s sendmany \"\" \"{\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002}\"",ASSETCHAINS_SYMBOL,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr); From cb840494a688339dc98323d905fca8723481dc46 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 12:04:58 -1100 Subject: [PATCH 127/135] Test --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index d2d1b426f..2340ff58b 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -574,7 +574,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); } From 7ebf06aeddf390b665e17dfe15b75dcd2838e007 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 21:43:52 -1100 Subject: [PATCH 128/135] MAX_MONEY cap 10000100000 --- src/komodo_utils.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index fe6397dcd..104b5ae08 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1641,8 +1641,8 @@ void komodo_args(char *argv0) MAX_MONEY += (MAX_MONEY * ASSETCHAINS_COMMISSION) / SATOSHIDEN; if ( ASSETCHAINS_CC >= KOMODO_FIRSTFUNGIBLEID && MAX_MONEY < 1000000LL*SATOSHIDEN ) MAX_MONEY = 1000000LL*SATOSHIDEN; - if ( MAX_MONEY <= 0 || MAX_MONEY > 1000000000LL*SATOSHIDEN ) - MAX_MONEY = 1000000000LL*SATOSHIDEN; + if ( MAX_MONEY <= 0 || MAX_MONEY > 10000100000LL*SATOSHIDEN ) + MAX_MONEY = 10000100000LL*SATOSHIDEN; //fprintf(stderr,"MAX_MONEY %llu %.8f\n",(long long)MAX_MONEY,(double)MAX_MONEY/SATOSHIDEN); //printf("baseid.%d MAX_MONEY.%s %.8f\n",baseid,ASSETCHAINS_SYMBOL,(double)MAX_MONEY/SATOSHIDEN); ASSETCHAINS_P2PPORT = komodo_port(ASSETCHAINS_SYMBOL,ASSETCHAINS_SUPPLY,&ASSETCHAINS_MAGIC,extraptr,extralen); From 87acaff05680c0c080e6a0f590cd6e3bac848854 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 22:14:58 -1100 Subject: [PATCH 129/135] Delete after orphaning --- src/cc/dice.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 2340ff58b..07c735f79 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -394,6 +394,7 @@ void *dicefinish(void *_ptr) fprintf(stderr,"send refund!\n"); mySenddicetransaction(ptr->rawtx,ptr->entropyused,ptr->entropyvout,ptr->bettxid,ptr->betTx,ptr->funcid,ptr); } + dicefinish_delete(ptr); continue; } } From 4ae77bc74eb9b9920aa95cbc0228fc103f95aaf4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 22:41:06 -1100 Subject: [PATCH 130/135] Refund -> locked --- src/cc/dice.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 07c735f79..693648897 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1117,11 +1117,12 @@ uint64_t AddDiceInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK unstringbits(sstr,sbits); if ( sbits == refsbits && (funcid == 'F' && reffundingtxid == txid) || reffundingtxid == fundingtxid ) { - if ( funcid == 'F' || funcid == 'E' || funcid == 'W' || funcid == 'L' || funcid == 'T' ) + if ( funcid == 'R' || funcid == 'F' || funcid == 'E' || funcid == 'W' || funcid == 'L' || funcid == 'T' ) { if ( total != 0 && maxinputs != 0 ) { - fprintf(stderr,"use (%c) %.8f %s %s/v%d\n",funcid,(double)tx.vout[0].nValue/COIN,sstr,uint256_str(str,txid),vout); + if ( funcid == 'R' ) + fprintf(stderr,">>>>>>>>>>>> use (%c) %.8f %s %s/v%d\n",funcid,(double)tx.vout[0].nValue/COIN,sstr,uint256_str(str,txid),vout); mtx.vin.push_back(CTxIn(txid,vout,CScript())); } totalinputs += it->second.satoshis; @@ -1178,7 +1179,7 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit if ( (funcid == 'F' && reffundingtxid == txid) || reffundingtxid == fundingtxid ) { //fprintf(stderr,"%d: %s/v%d (%c %.8f) %.8f %.8f\n",n,uint256_str(str,txid),vout,funcid,(double)it->second.satoshis/COIN,(double)totalinputs/COIN,(double)sum/COIN); - if ( (nValue= IsDicevout(cp,tx,vout,refsbits,reffundingtxid)) >= 10000 && (funcid == 'F' || funcid == 'E' || funcid == 'W' || funcid == 'L' || funcid == 'T') ) + if ( (nValue= IsDicevout(cp,tx,vout,refsbits,reffundingtxid)) >= 10000 && (funcid == 'R' || funcid == 'F' || funcid == 'E' || funcid == 'W' || funcid == 'L' || funcid == 'T') ) { if ( funcid == 'L' || funcid == 'W' || funcid == 'E' ) n++; @@ -1242,7 +1243,7 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit } } } - else if ( funcid != 'B' ) + else if ( 0 && funcid != 'B' ) fprintf(stderr,"%s %c refsbits.%llx sbits.%llx nValue %.8f\n",uint256_str(str,txid),funcid,(long long)refsbits,(long long)sbits,(double)nValue/COIN); } //else fprintf(stderr,"else case funcid (%c) %d %s vs %s\n",funcid,funcid,uint256_str(str,reffundingtxid),uint256_str(str2,fundingtxid)); } //else fprintf(stderr,"funcid.%d %c skipped %.8f\n",funcid,funcid,(double)tx.vout[vout].nValue/COIN); @@ -1578,7 +1579,8 @@ std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t &entropyv mtx.vin.push_back(CTxIn(bettxid,0,CScript())); mtx.vin.push_back(CTxIn(bettxid,1,CScript())); funcid = 'R'; - mtx.vout.push_back(CTxOut(betTx.vout[0].nValue,fundingPubKey)); + mtx.vout.push_back(MakeCC1vout(cp->evalcode,betTx.vout[0].nValue,dicepk)); + //mtx.vout.push_back(CTxOut(betTx.vout[0].nValue,fundingPubKey)); mtx.vout.push_back(CTxOut(txfee,fundingPubKey)); mtx.vout.push_back(CTxOut(betTx.vout[1].nValue,betTx.vout[2].scriptPubKey)); *resultp = 1; From ba291f4caf5bc4180ff9e4a6a4a91f908ed4a825 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 23:06:51 -1100 Subject: [PATCH 131/135] Dealer0 thread --- src/cc/dice.cpp | 166 +++++++++++++++++++----------------------------- 1 file changed, 66 insertions(+), 100 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 693648897..c3cb3560c 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -473,61 +473,7 @@ void *dicefinish(void *_ptr) } } } - else if ( 0 && newblock != 0 ) - dicefinish_utxosget(num,0,0,coinaddr); free(utxos); - if ( 0 && newblock != 0 && num < DICE_MINUTXOS ) - { - char *cmd = (char *)malloc(100 * 128); - sprintf(cmd,"./komodo-cli -ac_name=%s sendmany \"\" \"{\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002}\"",ASSETCHAINS_SYMBOL,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr); - n = sqrt((DICE_MINUTXOS - num) / 100)*2 + 1; - fprintf(stderr,"num normal 0.0002 utxos.%d < %d -> n.%d\n",num,DICE_MINUTXOS,n); - for (i=0; i 64 && is_hexstr((char *)res.c_str(),0) > 64 ) - { - if ( DecodeHexTx(tx,res) != 0 ) - { - //LOCK(cs_main); - if ( myAddtomempool(tx) != 0 ) - { - fprintf(stderr,"ENTROPY %s: %d of %d, %d\n",tx.GetHash().GetHex().c_str(),i,n,DICE_MINUTXOS - entropytxs); - RelayTransaction(tx); - } else break; - } else break; - } else break; - } - } - } - } } } if ( (newht= KOMODO_INSYNC) == 0 || newht == lastheight ) @@ -1680,8 +1626,70 @@ std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t &entropyv return("couldnt find bettx or entropytx"); } +void *dealer0_loop(void *_arg) +{ + char *planstr = (char *)_arg; + CTransaction tx; CPubKey mypk,dicepk; uint64_t entropyval; uint256 entropytxid,fundingtxid; int32_t entropytxs,i,n,num; CScript fundingPubKey; struct CCcontract_info *cp,C; char coinaddr[64]; std::string res; int64_t minbet,maxbet,maxodds,timeoutblocks; uint64_t refsbits,txfee = 10000; + if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,refsbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) + { + fprintf(stderr,"error initializing dealer0_loop\n"); + exit(-1); + } + fprintf(stderr,"dealer0 node running\n"); + while ( 1 ) + { + DicePlanFunds(entropyval,entropytxid,refsbits,cp,dicepk,fundingtxid,entropytxs,false); + if ( entropytxs < DICE_MINUTXOS ) + { + n = sqrt(DICE_MINUTXOS - entropytxs) + 10; + for (i=0; i 64 && is_hexstr((char *)res.c_str(),0) > 64 ) + { + if ( DecodeHexTx(tx,res) != 0 ) + { + LOCK(cs_main); + if ( myAddtomempool(tx) != 0 ) + { + fprintf(stderr,"ENTROPY %s: %d of %d, %d\n",tx.GetHash().GetHex().c_str(),i,n,DICE_MINUTXOS - entropytxs); + RelayTransaction(tx); + } else break; + } else break; + } else break; + } + } + pubkey2addr(coinaddr,Mypubkey().data()); + dicefinish_utxosget(num,0,0,coinaddr); + fprintf(stderr,"have %d 0.0002 utxos, need %d\n",num,DICE_MINUTXOS); + if ( num < DICE_MINUTXOS ) // this deadlocks, need to put it in a different thread + { + char *cmd = (char *)malloc(100 * 128); + sprintf(cmd,"./komodo-cli -ac_name=%s sendmany \"\" \"{\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002}\"",ASSETCHAINS_SYMBOL,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr); + n = sqrt((DICE_MINUTXOS - num) / 100)*2 + 1; + fprintf(stderr,"num normal 0.0002 utxos.%d < %d -> n.%d\n",num,DICE_MINUTXOS,n); + for (i=0; i 64 && is_hexstr((char *)res.c_str(),0) > 64 ) - { - if ( DecodeHexTx(tx,res) != 0 ) - { - //LOCK(cs_main); - if ( myAddtomempool(tx) != 0 ) - { - fprintf(stderr,"ENTROPY %s: %d of %d, %d\n",tx.GetHash().GetHex().c_str(),i,n,DICE_MINUTXOS - entropytxs); - RelayTransaction(tx); - } else break; - } else break; - } else break; - } - } - pubkey2addr(coinaddr,Mypubkey().data()); - dicefinish_utxosget(num,0,0,coinaddr); - fprintf(stderr,"have %d 0.0002 utxos, need %d\n",num,DICE_MINUTXOS); - if ( 0 && num < DICE_MINUTXOS ) // this deadlocks, need to put it in a different thread - { - char *cmd = (char *)malloc(100 * 128); - sprintf(cmd,"./komodo-cli -ac_name=%s sendmany \"\" \"{\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002,\\\"%s\\\":0.0002}\"",ASSETCHAINS_SYMBOL,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr,coinaddr); - n = sqrt((DICE_MINUTXOS - num) / 100)*2 + 1; - fprintf(stderr,"num normal 0.0002 utxos.%d < %d -> n.%d\n",num,DICE_MINUTXOS,n); - for (i=0; i Date: Sun, 11 Nov 2018 23:17:39 -1100 Subject: [PATCH 132/135] dealer0_fundingtxid --- src/cc/dice.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index c3cb3560c..f0f0ccb92 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -419,7 +419,7 @@ void *dicefinish(void *_ptr) 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) { @@ -1626,11 +1626,12 @@ std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t &entropyv return("couldnt find bettx or entropytx"); } +static uint256 dealer0_fundingtxid; void *dealer0_loop(void *_arg) { char *planstr = (char *)_arg; - CTransaction tx; CPubKey mypk,dicepk; uint64_t entropyval; uint256 entropytxid,fundingtxid; int32_t entropytxs,i,n,num; CScript fundingPubKey; struct CCcontract_info *cp,C; char coinaddr[64]; std::string res; int64_t minbet,maxbet,maxodds,timeoutblocks; uint64_t refsbits,txfee = 10000; - if ( (cp= Diceinit(fundingPubKey,fundingtxid,&C,planstr,txfee,mypk,dicepk,refsbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) + CTransaction tx; CPubKey mypk,dicepk; uint64_t entropyval; uint256 entropytxid; int32_t entropytxs,i,n,num; CScript fundingPubKey; struct CCcontract_info *cp,C; char coinaddr[64]; std::string res; int64_t minbet,maxbet,maxodds,timeoutblocks; uint64_t refsbits,txfee = 10000; + if ( (cp= Diceinit(fundingPubKey,dealer0_fundingtxid,&C,planstr,txfee,mypk,dicepk,refsbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 ) { fprintf(stderr,"error initializing dealer0_loop\n"); exit(-1); @@ -1751,6 +1752,7 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx if ( didinit == 0 && KOMODO_DEALERNODE == 0 && scriptPubKey == fundingPubKey ) { strcpy(_planstr,planstr); + dealer0_fundingtxid = fundingtxid; if ( pthread_create((pthread_t *)malloc(sizeof(pthread_t)),NULL,dealer0_loop,_planstr) == 0 ) didinit = 1; } From 1978a02179124cd73ee296d6457f8ef9d5da1134 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 23:19:27 -1100 Subject: [PATCH 133/135] dealer0_fundingtxid --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index f0f0ccb92..3eb98c59f 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1639,7 +1639,7 @@ void *dealer0_loop(void *_arg) fprintf(stderr,"dealer0 node running\n"); while ( 1 ) { - DicePlanFunds(entropyval,entropytxid,refsbits,cp,dicepk,fundingtxid,entropytxs,false); + DicePlanFunds(entropyval,entropytxid,refsbits,cp,dicepk,dealer0_fundingtxid,entropytxs,false); if ( entropytxs < DICE_MINUTXOS ) { n = sqrt(DICE_MINUTXOS - entropytxs) + 10; From 466678352a192f916a0031ee8a12c7f87062c611 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 23:20:02 -1100 Subject: [PATCH 134/135] dealer0_fundingtxid --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 3eb98c59f..2bf1820f9 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1645,7 +1645,7 @@ void *dealer0_loop(void *_arg) n = sqrt(DICE_MINUTXOS - entropytxs) + 10; for (i=0; i 64 && is_hexstr((char *)res.c_str(),0) > 64 ) { if ( DecodeHexTx(tx,res) != 0 ) From 931812c28a373f5e3912dd6ba9c02b84851ea774 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 11 Nov 2018 23:24:28 -1100 Subject: [PATCH 135/135] Minutxos -> 10000 --- src/cc/dice.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 2bf1820f9..c68a69f73 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -98,7 +98,7 @@ What is needed is for the dealer node to track the entropy tx that was already b #include "../compat/endian.h" #define MAX_ENTROPYUSED 8192 -#define DICE_MINUTXOS 7777 +#define DICE_MINUTXOS 10000 extern int32_t KOMODO_INSYNC; pthread_mutex_t DICE_MUTEX,DICEREVEALED_MUTEX;