From cf6e8d22ed6cd6c9ed46a2490be20d9483339746 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 1 Nov 2018 23:53:57 +0800 Subject: [PATCH 1/7] enable bet flood :D --- src/cc/CCtx.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 60b52fba0..be8776a8e 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -276,11 +276,11 @@ int32_t CC_vinselect(int32_t *aboveip,int64_t *abovep,int32_t *belowip,int64_t * abovei = belowi = -1; for (above=below=i=0; i 500 ) { - // if ( (rand() % 100) < 80 ) - // continue; - //} + // Filter to randomly pick utxo to avoid conflicts, and having multiple CC choose the same ones. + if ( numunspents > 200 ) { + if ( (rand() % 100) < 90 ) + continue; + } if ( (atx_value= utxos[i].nValue) <= 0 ) continue; if ( atx_value == value ) From dd5a56be3fc047b01f382bebf9eca61a4913b182 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 1 Nov 2018 23:54:56 +0800 Subject: [PATCH 2/7] print --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index f6c8520d8..837e380de 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -4322,7 +4322,7 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C if (AcceptToMemoryPool(mempool, state, tx, false, &fMissingInputs, !fOverrideFees) == false ) invalidtxs++; - else fprintf(stderr, "added mempool tx back to mempool\n"); + //else fprintf(stderr, "added mempool tx back to mempool\n"); } if ( 0 && invalidtxs > 0 ) fprintf(stderr, "number of invalid txs: %d\n",invalidtxs ); From 29d67993c83cd6b9fcd17c6de2ba15f7760e1c2b Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 13 Nov 2018 23:28:36 +0800 Subject: [PATCH 3/7] getblock template with mode:disablecb this allows a pool to use the daemons coinbase tx rather than build its own. --- src/rpcmining.cpp | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 0a2b56ca9..efd5be36f 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -518,10 +518,10 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) #endif } - std::string strMode = "template"; UniValue lpval = NullUniValue; // TODO: Re-enable coinbasevalue once a specification has been written bool coinbasetxn = true; + std::string strMode; if (params.size() > 0) { const UniValue& oparam = params[0].get_obj(); @@ -530,12 +530,15 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) strMode = modeval.get_str(); else if (modeval.isNull()) { - /* Do nothing */ + strMode = "template"; } else throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); lpval = find_value(oparam, "longpollid"); + if (strMode == "disablecb") + coinbasetxn = false; + if (strMode == "proposal") { const UniValue& dataval = find_value(oparam, "data"); @@ -567,9 +570,6 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) } } - if (strMode != "template") - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid mode"); - if (vNodes.empty()) throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Komodo is not connected!"); @@ -673,8 +673,8 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) uint256 txHash = tx.GetHash(); setTxIndex[txHash] = i++; - if (tx.IsCoinBase() && !coinbasetxn) - continue; + //if (tx.IsCoinBase() && !coinbasetxn) + // continue; UniValue entry(UniValue::VOBJ); @@ -694,7 +694,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) entry.push_back(Pair("fee", pblocktemplate->vTxFees[index_in_template])); entry.push_back(Pair("sigops", pblocktemplate->vTxSigOps[index_in_template])); - if (tx.IsCoinBase()) { + if (tx.IsCoinBase() && coinbasetxn == true ) { // Show founders' reward if it is required //if (pblock->vtx[0].vout.size() > 1) { // Correct this if GetBlockTemplate changes the order @@ -729,10 +729,10 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) if (coinbasetxn) { assert(txCoinbase.isObject()); result.push_back(Pair("coinbasetxn", txCoinbase)); - } else { - result.push_back(Pair("coinbaseaux", aux)); - result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue)); - } + } // else { + // result.push_back(Pair("coinbaseaux", aux)); + // result.push_back(Pair("coinbasevalue", (int64_t)pblock->vtx[0].vout[0].nValue)); + //} result.push_back(Pair("longpollid", chainActive.LastTip()->GetBlockHash().GetHex() + i64tostr(nTransactionsUpdatedLast))); if ( ASSETCHAINS_STAKED != 0 ) { @@ -756,6 +756,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) return result; } + class submitblock_StateCatcher : public CValidationInterface { public: From 3d4e48cdd1e19c727cb1e874bc7114b335ff9f51 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 13 Nov 2018 23:33:13 +0800 Subject: [PATCH 4/7] update setpubkey RPC to be comptible with the node-stratum-pool fork --- src/wallet/rpcwallet.cpp | 46 ++++++++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 1d3ff6a1e..d50674559 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4921,7 +4921,7 @@ bool pubkey2addr(char *destaddr,uint8_t *pubkey33); UniValue setpubkey(const UniValue& params, bool fHelp) { UniValue result(UniValue::VOBJ); - if ( fHelp || params.size() != 1 ) + if ( fHelp || params.size() > 1 ) throw runtime_error( "setpubkey\n" "\nSets the -pubkey if the daemon was not started with it, if it was already set, it returns the pubkey.\n" @@ -4938,16 +4938,10 @@ UniValue setpubkey(const UniValue& params, bool fHelp) + HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") ); -#ifdef ENABLE_WALLET LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); -#else - LOCK(cs_main); -#endif char Raddress[18]; uint8_t pubkey33[33]; - extern uint8_t NOTARY_PUBKEY33[]; - extern std::string NOTARY_PUBKEY; if ( NOTARY_PUBKEY33[0] == 0 ) { if (strlen(params[0].get_str().c_str()) == 66) { decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); @@ -4960,23 +4954,39 @@ UniValue setpubkey(const UniValue& params, bool fHelp) if (isValid) { CTxDestination dest = address.Get(); - string currentAddress = address.ToString(); - result.push_back(Pair("address", currentAddress)); -#ifdef ENABLE_WALLET isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; - result.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); -#endif + if ( mine == ISMINE_NO ) { + result.push_back(Pair("WARNING", "privkey for this pubkey is not imported to wallet!")); + } else { + result.push_back(Pair("ismine", "true")); + std::string notaryname; + if ( (IS_STAKED_NOTARY= StakedNotaryID(notaryname, Raddress)) > -1 ) { + result.push_back(Pair("IsNotary", notaryname)); + IS_KOMODO_NOTARY = 0; + } + } + NOTARY_PUBKEY = params[0].get_str(); + decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); + USE_EXTERNAL_PUBKEY = 1; + NOTARY_ADDRESS = address.ToString(); + } else { + result.push_back(Pair("error", "pubkey entered is invalid.")); } - NOTARY_PUBKEY = params[0].get_str(); - decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); } } else { result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); } } else { + if ( NOTARY_ADDRESS.empty() ) { + pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); + NOTARY_ADDRESS.assign(Raddress); + } result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); } - result.push_back(Pair("pubkey", NOTARY_PUBKEY)); + if ( NOTARY_PUBKEY33[0] != 0 && !NOTARY_ADDRESS.empty() ) { + result.push_back(Pair("address", NOTARY_ADDRESS)); + result.push_back(Pair("pubkey", NOTARY_PUBKEY)); + } return result; } @@ -5620,7 +5630,7 @@ UniValue gatewayswithdraw(const UniValue& params, bool fHelp) const CKeyStore& keystore = *pwalletMain; LOCK2(cs_main, pwalletMain->cs_wallet); bindtxid = Parseuint256((char *)params[0].get_str().c_str()); - coin = params[1].get_str(); + coin = params[1].get_str(); withdrawpub = ParseHex(params[2].get_str()); amount = atof((char *)params[3].get_str().c_str()) * COIN; hex = GatewaysWithdraw(0,bindtxid,coin,pubkey2pk(withdrawpub),amount); @@ -5673,7 +5683,7 @@ UniValue gatewaysmultisig(const UniValue& params, bool fHelp) 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"); const CKeyStore& keystore = *pwalletMain; - LOCK2(cs_main, pwalletMain->cs_wallet); + LOCK2(cs_main, pwalletMain->cs_wallet); txidaddr = (char *)params[0].get_str().c_str(); return(GatewaysMultisig(txidaddr)); } @@ -5686,7 +5696,7 @@ UniValue gatewayspartialsign(const UniValue& params, bool fHelp) 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"); const CKeyStore& keystore = *pwalletMain; - LOCK2(cs_main, pwalletMain->cs_wallet); + LOCK2(cs_main, pwalletMain->cs_wallet); txid = Parseuint256((char *)params[0].get_str().c_str()); coin = params[1].get_str(); parthex = params[2].get_str(); From 3276079b1d11e9a78387689a632c4770e7c9c867 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 13 Nov 2018 23:51:37 +0800 Subject: [PATCH 5/7] is not for staked. --- src/wallet/rpcwallet.cpp | 47 +++++++++++++++++----------------------- 1 file changed, 20 insertions(+), 27 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index d50674559..b32af4f80 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4921,10 +4921,10 @@ bool pubkey2addr(char *destaddr,uint8_t *pubkey33); UniValue setpubkey(const UniValue& params, bool fHelp) { UniValue result(UniValue::VOBJ); - if ( fHelp || params.size() > 1 ) + if ( fHelp || params.size() != 1 ) throw runtime_error( "setpubkey\n" - "\nSets the -pubkey if the daemon was not started with it, if it was already set, it returns the pubkey.\n" + "\nSets the -pubkey if the daemon was not started with it, if it was already set, it returns the pubkey, and its Raddress.\n" "\nArguments:\n" "1. \"pubkey\" (string) pubkey to set.\n" "\nResult:\n" @@ -4938,10 +4938,16 @@ UniValue setpubkey(const UniValue& params, bool fHelp) + HelpExampleRpc("setpubkey", "02f7597468703c1c5c8465dd6d43acaae697df9df30bed21494d193412a1ea193e") ); +#ifdef ENABLE_WALLET LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL); +#else + LOCK(cs_main); +#endif char Raddress[18]; uint8_t pubkey33[33]; + extern uint8_t NOTARY_PUBKEY33[]; + extern std::string NOTARY_PUBKEY; if ( NOTARY_PUBKEY33[0] == 0 ) { if (strlen(params[0].get_str().c_str()) == 66) { decode_hex(pubkey33,33,(char *)params[0].get_str().c_str()); @@ -4954,39 +4960,26 @@ UniValue setpubkey(const UniValue& params, bool fHelp) if (isValid) { CTxDestination dest = address.Get(); + string currentAddress = address.ToString(); + result.push_back(Pair("address", currentAddress)); +#ifdef ENABLE_WALLET isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; - if ( mine == ISMINE_NO ) { - result.push_back(Pair("WARNING", "privkey for this pubkey is not imported to wallet!")); - } else { - result.push_back(Pair("ismine", "true")); - std::string notaryname; - if ( (IS_STAKED_NOTARY= StakedNotaryID(notaryname, Raddress)) > -1 ) { - result.push_back(Pair("IsNotary", notaryname)); - IS_KOMODO_NOTARY = 0; - } - } - NOTARY_PUBKEY = params[0].get_str(); - decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); - USE_EXTERNAL_PUBKEY = 1; - NOTARY_ADDRESS = address.ToString(); - } else { - result.push_back(Pair("error", "pubkey entered is invalid.")); + result.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); +#endif } + NOTARY_PUBKEY = params[0].get_str(); + decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str()); } } else { result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string.")); } } else { - if ( NOTARY_ADDRESS.empty() ) { - pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); - NOTARY_ADDRESS.assign(Raddress); - } - result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon.")); - } - if ( NOTARY_PUBKEY33[0] != 0 && !NOTARY_ADDRESS.empty() ) { - result.push_back(Pair("address", NOTARY_ADDRESS)); - result.push_back(Pair("pubkey", NOTARY_PUBKEY)); + result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon, pubkey in use is below.")); + pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); + std::string address_ret.assign(Raddress); + result.push_back(Pair("address",address_ret)); } + result.push_back(Pair("pubkey", NOTARY_PUBKEY)); return result; } From f4965c1c69f58c4198e853eb0ca36f8aba438bf7 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Tue, 13 Nov 2018 23:55:23 +0800 Subject: [PATCH 6/7] fix --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b32af4f80..d8db86172 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4976,7 +4976,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp) } else { result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon, pubkey in use is below.")); pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33); - std::string address_ret.assign(Raddress); + std::string address_ret; address_ret.assign(Raddress); result.push_back(Pair("address",address_ret)); } result.push_back(Pair("pubkey", NOTARY_PUBKEY)); From c1ba0e3c59f6368df0323dc1ae6c6d6bb22d5228 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Thu, 15 Nov 2018 03:36:26 +0800 Subject: [PATCH 7/7] disable utxo fiter CCtx.cpp --- src/cc/CCtx.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 0b78c61d4..db90912a1 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -276,10 +276,10 @@ int32_t CC_vinselect(int32_t *aboveip,int64_t *abovep,int32_t *belowip,int64_t * for (above=below=i=0; i 200 ) { - if ( (rand() % 100) < 90 ) - continue; - } + //if ( numunspents > 200 ) { + // if ( (rand() % 100) < 90 ) + // continue; + //} if ( (atx_value= utxos[i].nValue) <= 0 ) continue; if ( atx_value == value )