is this working now?

This commit is contained in:
blackjok3r
2018-11-03 16:35:51 +08:00
parent c52c8d2a37
commit 4d85706859
4 changed files with 23 additions and 11 deletions

View File

@@ -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
}

View File

@@ -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");

View File

@@ -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());

View File

@@ -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++) {
@@ -1253,6 +1253,8 @@ 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.
// 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");
}
}