diff --git a/src/komodo_notary.h b/src/komodo_notary.h index dafcbe820..e02860414 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -234,7 +234,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(elected_pubkeys0[i],33,(char *)Notaries_elected0[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)Notaries_elected0[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)elected_pubkeys0[i]); pthread_mutex_unlock(&komodo_mutex); #endif } @@ -254,7 +254,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(elected_pubkeys1[i],33,(char *)Notaries_elected1[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)Notaries_elected1[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)elected_pubkeys1[i]); pthread_mutex_unlock(&komodo_mutex); #endif } @@ -281,7 +281,6 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(staked_pubkeys1[i],33,(char *)notaries_STAKED1[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - fprintf(stderr, "pubkey?: %s\n",staked_pubkeys1[i]); pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys1[i]); pthread_mutex_unlock(&komodo_mutex); #endif @@ -303,7 +302,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(staked_pubkeys2[i],33,(char *)notaries_STAKED2[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED2[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys2[i]); pthread_mutex_unlock(&komodo_mutex); #endif } @@ -323,7 +322,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(staked_pubkeys3[i],33,(char *)notaries_STAKED3[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED3[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys3[i]); pthread_mutex_unlock(&komodo_mutex); #endif } @@ -342,7 +341,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam decode_hex(staked_pubkeys4[i],33,(char *)notaries_STAKED4[i][1]); #ifdef SERVER pthread_mutex_lock(&komodo_mutex); - pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED4[i][1]); + pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys4[i]); pthread_mutex_unlock(&komodo_mutex); #endif } diff --git a/src/script/standard.cpp b/src/script/standard.cpp index 2c3f4afc7..9aa02bfb7 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -244,7 +244,6 @@ bool ExtractDestination(const CScript& scriptPubKey, CTxDestination& addressRet) if (whichType == TX_PUBKEY) { CPubKey pubKey(vSolutions[0]); - fprintf(stderr, "pubkey in exdest: %s\n",scriptPubKey.ToString().c_str()); if (!pubKey.IsValid()) { fprintf(stderr,"TX_PUBKEY invalid pubkey\n"); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 862df0c0f..dc0b19ecc 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -4959,6 +4959,7 @@ UniValue channelsaddress(const UniValue& params, bool fHelp) } bool pubkey2addr(char *destaddr,uint8_t *pubkey33); +extern int32_t IS_KOMODO_NOTARY; UniValue setpubkey(const UniValue& params, bool fHelp) { @@ -5005,9 +5006,20 @@ UniValue setpubkey(const UniValue& params, bool fHelp) NOTARY_ADDRESS = address.ToString(); result.push_back(Pair("address", NOTARY_ADDRESS)); #ifdef ENABLE_WALLET - isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO; - result.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false)); + isminetype mine = pwalletMain; + if ( IsMine(*pwalletMain, dest) == 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 ( StakedNotaryID(notaryname, Raddress) != -1 ) { + IS_KOMODO_NOTARY = 1; + result.push_back(Pair("IsNotary", notaryname)); + } + } #endif + } 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()); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index a73ea31fe..8a8f96d8f 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1213,7 +1213,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0) { - if ( NOTARY_ADDRESS != "" ) + if ( NOTARY_ADDRESS != "" && IS_KOMODO_NOTARY == 1 ) { int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0; for (size_t i = 0; i < tx.vin.size(); i++) { @@ -1252,7 +1252,9 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl } else if ( numvinIsOurs < tx.vin.size() ) { // this means we were in a multi sig, we wil remove the utxo we spent from our wallet, - // IF there exisited a function for that. + // IF there exisited a function for that. + // Maybe check if there are any vouts unspetn in this TX + // then purge the TX from wallet if all spent? fprintf(stderr, "There are vins that are not ours, notarisation?\n"); } }