diff --git a/src/komodo.h b/src/komodo.h index ecda8ef52..18f32f4fa 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -33,12 +33,12 @@ #include "uthash.h" #include "utlist.h" -#include "komodo_structs.h" +int32_t gettxout_scriptPubKey(uint8_t *scriptPubkey,int32_t maxsize,uint256 txid,int32_t n); +#include "komodo_structs.h" #include "komodo_globals.h" #include "komodo_utils.h" - void komodo_setkmdheight(int32_t kmdheight) { if ( kmdheight > KMDHEIGHT ) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index c212ef7bb..21cc0e619 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -463,12 +463,27 @@ void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height) } } -int32_t komodo_currentheight(); int8_t komodo_minerid(int32_t height) { - static uint32_t depth; - int32_t notaryid; CBlockIndex *pindex; uint8_t pubkey33[33]; - if ( Minerids[height] >= -1 ) + //static uint32_t depth; + int32_t notaryid,num,i; CBlockIndex *pindex; uint8_t pubkeys[64][33],script[35]; + if ( (pindex= chainActive[height]) != 0 ) + { + if ( gettxout_scriptPubKey(script,sizeof(script),pindex->vtx[0].GetHash(),0) == 35 ) + { + if ( (num= komodo_notaries(pubkeys,height)) > 0 ) + { + for (i=0; i= -1 ) { printf("cached[%d] -> %d\n",height,Minerids[height]); return(Minerids[height]); @@ -493,7 +508,7 @@ int8_t komodo_minerid(int32_t height) depth--; return(notaryid); } - } + }*/ return(-2); } @@ -510,7 +525,7 @@ int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33]) Minerids[height-i] = komodo_minerid(height-i); if ( Minerids[height - i] == -2 ) { - //fprintf(stderr,"second -2 for Minerids[%d] current.%d\n",height-i,komodo_currentheight()); + fprintf(stderr,"second -2 for Minerids[%d] current.%d\n",height-i,komodo_currentheight()); return(-2); } } diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index ae9f41540..fa5a5e9ea 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -589,6 +589,29 @@ Value gettxout(const Array& params, bool fHelp) return ret; } +int32_t gettxout_scriptPubKey(uint8_t *scriptPubkey,int32_t maxsize,uint256 txid,int32_t n) +{ + int32_t i,m; uint8_t *ptr; + LOCK(cs_main); + CCoins coins; + if (fMempool) + { + LOCK(mempool.cs); + CCoinsViewMemPool view(pcoinsTip,mempool); + if ( view.GetCoins(txid,coins) == 0 ) + return(-1); + mempool.pruneSpent(txid, coins); // TODO: this should be done by the CCoinsViewMemPool + } else if ( pcoinsTip->GetCoins(txid,coins) == 0 ) + return(-1); + if ( n < 0 || (unsigned int)n >= coins.vout.size() || coins.vout[n].IsNull() ) + return(-1); + ptr = (uint8_t *)coins.vout[n].scriptPubKey.data(); + m = coins.vout[n].scriptPubKey.size(); + for (i=0; i 2)