From 7bfc207ada45b4b0759d28de0a0de252c2beef37 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 3 Oct 2016 10:20:27 -0300 Subject: [PATCH] test --- src/bitcoind.cpp | 6 ++++-- src/komodo.h | 11 +++++++++-- src/miner.cpp | 6 +++--- src/pow.cpp | 4 ++-- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 3f7d02ae4..285c747cc 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -53,7 +53,7 @@ void WaitForShutdown(boost::thread_group* threadGroup) // // Start // -extern int32_t IS_KOMODO_NOTARY; +extern int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY; extern std::string NOTARY_PUBKEY; bool AppInit(int argc, char* argv[]) @@ -111,8 +111,10 @@ bool AppInit(int argc, char* argv[]) } IS_KOMODO_NOTARY = GetBoolArg("-notary", false); NOTARY_PUBKEY = GetArg("-pubkey", ""); + if ( strlen(NOTARY_PUBKEY.c_str()) == 66 ) + USE_EXTERNAL_PUBKEY = 1; fprintf(stderr,"IS_KOMODO_NOTARY %d %s\n",IS_KOMODO_NOTARY,NOTARY_PUBKEY.c_str()); - + // Command-line RPC bool fCommandLine = false; for (int i = 1; i < argc; i++) diff --git a/src/komodo.h b/src/komodo.h index 44a41cdd6..afc5ed249 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -19,11 +19,18 @@ #include #include -int32_t IS_KOMODO_NOTARY; +int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY; std::string NOTARY_PUBKEY; -int32_t komodo_is_notaryblock(void *block) +int32_t komodo_is_notaryblock(uint8_t *pblock,uint8_t *coinbase,uint8_t *minerout) { + int32_t i; + for (i=0; i<5; i++) + printf("%02x",coinbase[i]); + printf(" <- coinbase\n"); + for (i=0; i<35; i++) + printf("%02x",minerout[i]); + printf(" <- minerout\n"); return(0); } diff --git a/src/miner.cpp b/src/miner.cpp index 247ee729f..8efd74fdd 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -414,9 +414,9 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey) if (!reservekey.GetReservedKey(pubkey)) return NULL; scriptPubKey = CScript() << ToByteVector(pubkey) << OP_CHECKSIG; - if ( IS_KOMODO_NOTARY != 0 ) + if ( USE_EXTERNAL_PUBKEY != 0 ) { - fprintf(stderr,"use notary pubkey\n"); + //fprintf(stderr,"use notary pubkey\n"); scriptPubKey = CScript() << ParseHex(NOTARY_PUBKEY) << OP_CHECKSIG; } return CreateNewBlock(scriptPubKey); @@ -495,7 +495,7 @@ void static BitcoinMiner(CWallet *pwallet) } while (true); fprintf(stderr,"Found peers\n"); } - fprintf(stderr,"create new block\n"); + //fprintf(stderr,"create new block\n"); // // Create new block // diff --git a/src/pow.cpp b/src/pow.cpp index a4e9de2ea..5afafc83a 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -16,14 +16,14 @@ #include "sodium.h" -int32_t komodo_is_notaryblock(void *pblock); +int32_t komodo_is_notaryblock(uint8_t *pblock,uint8_t *coinbase,uint8_t *minerout); unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHeader *pblock, const Consensus::Params& params) { unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact(); // Genesis block - if (pindexLast == NULL || komodo_is_notaryblock((void *)pblock) != 0 ) + if (pindexLast == NULL || komodo_is_notaryblock((uint8_t *)pblock,(uint8_t *)pblock->vin[0].scriptSig,(uint8_t *)pblock->vout[0].scriptPubKey) != 0 ) return nProofOfWorkLimit; // Find the first block in the averaging interval