try this please work
This commit is contained in:
@@ -700,14 +700,6 @@ void komodo_init(int32_t height)
|
|||||||
{
|
{
|
||||||
pthread_mutex_init(&komodo_mutex,NULL);
|
pthread_mutex_init(&komodo_mutex,NULL);
|
||||||
decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str());
|
decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str());
|
||||||
#ifdef SERVER
|
|
||||||
char Raddress[18]; uint8_t pubkey33[33];
|
|
||||||
decode_hex(pubkey33,33,(char *)NOTARY_PUBKEY.c_str());
|
|
||||||
pubkey2addr((char *)Raddress,(uint8_t *)pubkey33);
|
|
||||||
CBitcoinAddress address(Raddress);
|
|
||||||
NOTARY_ADDRESS = address.ToString();
|
|
||||||
updateStakedNotary();
|
|
||||||
#endif
|
|
||||||
if ( height >= 0 )
|
if ( height >= 0 )
|
||||||
{
|
{
|
||||||
n = (int32_t)(sizeof(Notaries_genesis)/sizeof(*Notaries_genesis));
|
n = (int32_t)(sizeof(Notaries_genesis)/sizeof(*Notaries_genesis));
|
||||||
|
|||||||
@@ -1508,7 +1508,7 @@ void komodo_args(char *argv0)
|
|||||||
extern const char *Notaries_elected1[][2];
|
extern const char *Notaries_elected1[][2];
|
||||||
std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[256],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,baseid,len,n,extralen = 0;
|
std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[256],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,baseid,len,n,extralen = 0;
|
||||||
IS_KOMODO_NOTARY = GetBoolArg("-notary", false);
|
IS_KOMODO_NOTARY = GetBoolArg("-notary", false);
|
||||||
IS_STAKED_NOTARY = GetBoolArg("-stakednotary", false);
|
IS_STAKED_NOTARY = GetArg("-stakednotary", -1);
|
||||||
if ( GetBoolArg("-gen", false) != 0 )
|
if ( GetBoolArg("-gen", false) != 0 )
|
||||||
KOMODO_MININGTHREADS = GetArg("-genproclimit",1);
|
KOMODO_MININGTHREADS = GetArg("-genproclimit",1);
|
||||||
else KOMODO_MININGTHREADS = -1;
|
else KOMODO_MININGTHREADS = -1;
|
||||||
@@ -1516,7 +1516,7 @@ void komodo_args(char *argv0)
|
|||||||
fprintf(stderr,"KOMODO_EXCHANGEWALLET mode active\n");
|
fprintf(stderr,"KOMODO_EXCHANGEWALLET mode active\n");
|
||||||
DONATION_PUBKEY = GetArg("-donation", "");
|
DONATION_PUBKEY = GetArg("-donation", "");
|
||||||
NOTARY_PUBKEY = GetArg("-pubkey", "");
|
NOTARY_PUBKEY = GetArg("-pubkey", "");
|
||||||
if ( strlen(NOTARY_PUBKEY.c_str()) == 66 || IS_STAKED_NOTARY == false )
|
if ( strlen(NOTARY_PUBKEY.c_str()) == 66 )
|
||||||
{
|
{
|
||||||
USE_EXTERNAL_PUBKEY = 1;
|
USE_EXTERNAL_PUBKEY = 1;
|
||||||
if ( IS_KOMODO_NOTARY == 0 )
|
if ( IS_KOMODO_NOTARY == 0 )
|
||||||
@@ -1525,11 +1525,12 @@ void komodo_args(char *argv0)
|
|||||||
if ( strcmp(NOTARY_PUBKEY.c_str(),Notaries_elected1[i][1]) == 0 )
|
if ( strcmp(NOTARY_PUBKEY.c_str(),Notaries_elected1[i][1]) == 0 )
|
||||||
{
|
{
|
||||||
IS_KOMODO_NOTARY = 1;
|
IS_KOMODO_NOTARY = 1;
|
||||||
|
IS_STAKED_NOTARY = -1;
|
||||||
fprintf(stderr,"running as notary.%d %s\n",i,Notaries_elected1[i][0]);
|
fprintf(stderr,"running as notary.%d %s\n",i,Notaries_elected1[i][0]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//KOMODO_PAX = 1;
|
//KOMODO_PAX = 1;
|
||||||
} //else KOMODO_PAX = GetArg("-pax",0);
|
} //else KOMODO_PAX = GetArg("-pax",0);
|
||||||
name = GetArg("-ac_name","");
|
name = GetArg("-ac_name","");
|
||||||
if ( argv0 != 0 )
|
if ( argv0 != 0 )
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
#include "notaries_staked.h"
|
#include "notaries_staked.h"
|
||||||
#include "crosschain.h"
|
#include "crosschain.h"
|
||||||
|
#include "cc/CCinclude.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
extern char NOTARYADDRS[18][64];
|
extern char NOTARYADDRS[18][64];
|
||||||
@@ -116,21 +117,21 @@ int is_STAKED(const char *chain_name) {
|
|||||||
return(STAKED);
|
return(STAKED);
|
||||||
};
|
};
|
||||||
|
|
||||||
void updateStakedNotary() {
|
int8_t updateStakedNotary() {
|
||||||
std::string notaryname;
|
std::string notaryname;
|
||||||
//pthread_mutex_lock(&komodo_mutex);
|
char Raddress[18]; uint8_t pubkey33[33];
|
||||||
if (StakedNotaryID(notaryname,(char *)NOTARY_ADDRESS.c_str()) != -1 ) {
|
pthread_mutex_lock(&komodo_mutex);
|
||||||
IS_STAKED_NOTARY = 1;
|
decode_hex(pubkey33,33,(char *)NOTARY_PUBKEY.c_str());
|
||||||
IS_KOMODO_NOTARY = 0;
|
pubkey2addr((char *)Raddress,(uint8_t *)pubkey33);
|
||||||
} else {
|
NOTARY_ADDRESS.clear();
|
||||||
IS_STAKED_NOTARY = 0;
|
NOTARY_ADDRESS.assign(Raddress);
|
||||||
}
|
pthread_mutex_unlock(&komodo_mutex);
|
||||||
//pthread_mutex_unlock(&komodo_mutex);
|
return(StakedNotaryID(notaryname,Raddress));
|
||||||
}
|
}
|
||||||
|
|
||||||
int STAKED_era(int timestamp)
|
int STAKED_era(int timestamp)
|
||||||
{
|
{
|
||||||
int era;
|
int8_t era, didera;
|
||||||
if (timestamp <= STAKED_NOTARIES_TIMESTAMP1)
|
if (timestamp <= STAKED_NOTARIES_TIMESTAMP1)
|
||||||
era = 1;
|
era = 1;
|
||||||
else if (timestamp <= STAKED_NOTARIES_TIMESTAMP2 && timestamp >= (STAKED_NOTARIES_TIMESTAMP1 + STAKED_ERA_GAP))
|
else if (timestamp <= STAKED_NOTARIES_TIMESTAMP2 && timestamp >= (STAKED_NOTARIES_TIMESTAMP1 + STAKED_ERA_GAP))
|
||||||
@@ -142,9 +143,18 @@ int STAKED_era(int timestamp)
|
|||||||
else
|
else
|
||||||
era = 0;
|
era = 0;
|
||||||
// if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP.
|
// if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP.
|
||||||
if ( era > STAKED_ERA ) {
|
if ( era > STAKED_ERA || didera == 0 )
|
||||||
STAKED_ERA = era;
|
{
|
||||||
updateStakedNotary();
|
STAKED_ERA = era;
|
||||||
|
if ( NOTARY_PUBKEY33[0] != 0 && NOTARYADDRS[0] != 0 )
|
||||||
|
{
|
||||||
|
if (( IS_STAKED_NOTARY= updateStakedNotary()) > -1 )
|
||||||
|
{
|
||||||
|
IS_KOMODO_NOTARY = 0;
|
||||||
|
fprintf(stderr, "INIT.%d RADD.%s ERA.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era);
|
||||||
|
}
|
||||||
|
didera++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return(era);
|
return(era);
|
||||||
};
|
};
|
||||||
@@ -171,13 +181,15 @@ int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) {
|
int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname) {
|
||||||
|
int found = -1;
|
||||||
for (size_t i = 0; i < num_notaries; i++) {
|
for (size_t i = 0; i < num_notaries; i++) {
|
||||||
if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) {
|
if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) {
|
||||||
notaryname.assign(notaries_chosen[i][0]);
|
notaryname.assign(notaries_chosen[i][0]);
|
||||||
return(i);
|
found = i;
|
||||||
}
|
}
|
||||||
|
fprintf(stderr, "[%ld] %s\n",i,NOTARYADDRS[i]);
|
||||||
}
|
}
|
||||||
return(-1);
|
return(found);
|
||||||
}
|
}
|
||||||
|
|
||||||
CrosschainAuthority Choose_auth_STAKED(int chosen_era) {
|
CrosschainAuthority Choose_auth_STAKED(int chosen_era) {
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
#define NOTARIES_STAKED
|
#define NOTARIES_STAKED
|
||||||
|
|
||||||
#include "crosschain.h"
|
#include "crosschain.h"
|
||||||
|
#include "cc/CCinclude.h"
|
||||||
|
|
||||||
static const int STAKED_ERA_GAP = 777;
|
static const int STAKED_ERA_GAP = 777;
|
||||||
|
|
||||||
@@ -25,7 +26,7 @@ extern int num_notaries_STAKED4;
|
|||||||
|
|
||||||
int is_STAKED(const char *chain_name);
|
int is_STAKED(const char *chain_name);
|
||||||
int STAKED_era(int timestamp);
|
int STAKED_era(int timestamp);
|
||||||
void updateStakedNotary();
|
int8_t updateStakedNotary();
|
||||||
int8_t StakedNotaryID(std::string ¬aryname, char *Raddress);
|
int8_t StakedNotaryID(std::string ¬aryname, char *Raddress);
|
||||||
int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname);
|
int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname);
|
||||||
|
|
||||||
|
|||||||
@@ -4967,7 +4967,7 @@ UniValue channelsaddress(const UniValue& params, bool fHelp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool pubkey2addr(char *destaddr,uint8_t *pubkey33);
|
bool pubkey2addr(char *destaddr,uint8_t *pubkey33);
|
||||||
extern int32_t IS_KOMODO_NOTARY,IS_STAKED_NOTARY;
|
extern int32_t IS_KOMODO_NOTARY,IS_STAKED_NOTARY,USE_EXTERNAL_PUBKEY;
|
||||||
extern uint8_t NOTARY_PUBKEY33[];
|
extern uint8_t NOTARY_PUBKEY33[];
|
||||||
extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS;
|
extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS;
|
||||||
|
|
||||||
@@ -4994,7 +4994,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp)
|
|||||||
#ifdef ENABLE_WALLET
|
#ifdef ENABLE_WALLET
|
||||||
LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL);
|
LOCK2(cs_main, pwalletMain ? &pwalletMain->cs_wallet : NULL);
|
||||||
#else
|
#else
|
||||||
LOCK(cs_main);
|
LOCK2(cs_main);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char Raddress[18];
|
char Raddress[18];
|
||||||
@@ -5018,18 +5018,18 @@ UniValue setpubkey(const UniValue& params, bool fHelp)
|
|||||||
result.push_back(Pair("WARNING", "privkey for this pubkey is not imported to wallet!"));
|
result.push_back(Pair("WARNING", "privkey for this pubkey is not imported to wallet!"));
|
||||||
} else {
|
} else {
|
||||||
result.push_back(Pair("ismine", "true"));
|
result.push_back(Pair("ismine", "true"));
|
||||||
std::string notaryname;
|
|
||||||
if ( StakedNotaryID(notaryname, Raddress) != -1 ) {
|
|
||||||
IS_STAKED_NOTARY = 1;
|
|
||||||
result.push_back(Pair("IsNotary", notaryname));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
} else {
|
std::string notaryname;
|
||||||
|
if ( (IS_STAKED_NOTARY= StakedNotaryID(notaryname, Raddress)) > -1 ) {
|
||||||
|
result.push_back(Pair("IsNotary", notaryname));
|
||||||
|
IS_KOMODO_NOTARY = 0;
|
||||||
|
USE_EXTERNAL_PUBKEY = 1;
|
||||||
|
}
|
||||||
|
NOTARY_PUBKEY = params[0].get_str();
|
||||||
|
decode_hex(NOTARY_PUBKEY33,33,(char *)NOTARY_PUBKEY.c_str());
|
||||||
|
}
|
||||||
|
} else
|
||||||
result.push_back(Pair("error", "pubkey entered is invalid."));
|
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());
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string."));
|
result.push_back(Pair("error", "pubkey is wrong length, must be 66 char hex string."));
|
||||||
@@ -5037,7 +5037,7 @@ UniValue setpubkey(const UniValue& params, bool fHelp)
|
|||||||
} else {
|
} else {
|
||||||
result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon."));
|
result.push_back(Pair("error", "Can only set pubkey once, to change it you need to restart your daemon."));
|
||||||
}
|
}
|
||||||
if ( NOTARY_PUBKEY33[0] != 0 && NOTARY_ADDRESS.empty() == false ) {
|
if ( NOTARY_PUBKEY33[0] != 0 && !NOTARY_ADDRESS.empty() ) {
|
||||||
result.push_back(Pair("address", NOTARY_ADDRESS));
|
result.push_back(Pair("address", NOTARY_ADDRESS));
|
||||||
result.push_back(Pair("pubkey", NOTARY_PUBKEY));
|
result.push_back(Pair("pubkey", NOTARY_PUBKEY));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1214,7 +1214,7 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
|
|||||||
|
|
||||||
if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0)
|
if (fExisted || IsMine(tx) || IsFromMe(tx) || noteData.size() > 0)
|
||||||
{
|
{
|
||||||
if ( NOTARY_ADDRESS != "" && IS_STAKED_NOTARY == 1 )
|
if ( !NOTARY_ADDRESS.empty() && IS_STAKED_NOTARY > -1 )
|
||||||
{
|
{
|
||||||
int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0;
|
int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0;
|
||||||
for (size_t i = 0; i < tx.vin.size(); i++) {
|
for (size_t i = 0; i < tx.vin.size(); i++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user