From acbc7a942a604af3c2ce84e5cb25ec04f926de17 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 7 Jun 2018 06:31:20 -1100 Subject: [PATCH] Segid to validate address --- src/komodo_bitcoind.h | 7 +++++++ src/rpcmisc.cpp | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 12ba756fe..32d34c700 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -1080,6 +1080,13 @@ uint64_t komodo_commission(const CBlock *pblock) return(commission); } +uint32_t komodo_segid32(char *coinaddr) +{ + bits256 addrhash; + vcalc_sha256(0,(uint8_t *)&addrhash,(uint8_t *)address,(int32_t)strlen(address)); + return(addrhash.uints[0]); +} + uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeight,uint256 txid,int32_t vout,uint32_t blocktime,uint32_t prevtime,char *destaddr) { CBlockIndex *pindex; uint8_t hashbuf[128]; char address[64]; bits256 addrhash; arith_uint256 hashval; uint256 hash,pasthash; int64_t diff=0; int32_t segid,minage,i,iter=0; uint32_t txtime,winner = 0; uint64_t value,coinage,supply = ASSETCHAINS_SUPPLY + nHeight*ASSETCHAINS_REWARD/SATOSHIDEN; diff --git a/src/rpcmisc.cpp b/src/rpcmisc.cpp index c356ef994..95285b580 100644 --- a/src/rpcmisc.cpp +++ b/src/rpcmisc.cpp @@ -52,6 +52,7 @@ int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp); extern uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE; extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,KOMODO_LONGESTCHAIN; extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN]; +uint32_t komodo_segid32(char *coinaddr); int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp); #define KOMODO_VERSION "0.1.1" extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT; @@ -326,7 +327,7 @@ UniValue validateaddress(const UniValue& params, bool fHelp) CScript scriptPubKey = GetScriptForDestination(dest); ret.push_back(Pair("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end()))); - + ret.push_back(Pair("segid", komodo_segid(address.c_str()) & 3f)); #ifdef ENABLE_WALLET isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false));