From de0ced744452775bd7903e8d19a7c02b60b142c5 Mon Sep 17 00:00:00 2001 From: blackjok3r Date: Wed, 6 Feb 2019 17:00:21 +0800 Subject: [PATCH] Check for double signs on notarisation checks. revert minsigs to normal value. --- src/komodo_bitcoind.h | 6 ++++++ src/miner.cpp | 9 ++++++++- src/rpc/misc.cpp | 4 ++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index a40a174b1..a476e70e5 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1886,6 +1886,12 @@ uint64_t komodo_checknotarypay(CBlock *pblock,int32_t height) } } } + // check a notary didnt sign twice (this would be an invalid notarisation later on and cause problems) + std::set checkdupes( NotarisationNotaries.begin(), NotarisationNotaries.end() ); + if ( checkdupes.size() != NotarisationNotaries.size() ) { + fprintf(stderr, "Possible notarisation is signed multiple times by same notary. It is invalid.\n"); + return(0); + } const CChainParams& chainparams = Params(); const Consensus::Params &consensusParams = chainparams.GetConsensus(); uint64_t totalsats = 0; diff --git a/src/miner.cpp b/src/miner.cpp index 10bdb643f..e3eb8d262 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -367,7 +367,14 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 dPriority += (double)nValueIn * nConf; } if ( numSN != 0 && numNotaryVins >= numSN / 5 ) - fNotarisation = true; + { + // check a notary didnt sign twice (this would be an invalid notarisation later on and cause problems) + std::set checkdupes( NotarisationNotaries.begin(), NotarisationNotaries.end() ); + if ( checkdupes.size() != NotarisationNotaries.size() ) { + NotarisationNotaries.clear(); + fprintf(stderr, "possible notarisation is signed multiple times by same notary, passed as normal transaction.\n"); + } else fNotarisation = true; + } else NotarisationNotaries.clear(); diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 1e0e33c27..b60809da1 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -128,8 +128,8 @@ UniValue getiguanajson(const UniValue& params, bool fHelp) json.push_back(Pair("port",iguanaPort)); json.push_back(Pair("BTCminsigs",BTCminsigs)); - json.push_back(Pair("minsigs",2)); - json.push_back(Pair("seeds", seeds)); + json.push_back(Pair("minsigs",minsigs)); + json.push_back(Pair("seeds",seeds)); json.push_back(Pair("notaries",notaries)); return json; }