attempt to add Raddress array

This commit is contained in:
blackjok3r
2018-11-02 18:40:04 +08:00
parent 334314cef4
commit 85bbfadd2f
6 changed files with 80 additions and 25 deletions

View File

@@ -45,12 +45,12 @@ struct komodo_state KOMODO_STATES[34];
#define _COINBASE_MATURITY 100
int COINBASE_MATURITY = _COINBASE_MATURITY;//100;
int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1;
int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,ASSETCHAINS_STREAM,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,STAKED_ERA,KOMODO_CONNECTING = -1;
int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1;
std::string NOTARY_ADDRESS,ASSETCHAINS_OVERRIDE_ADDRESS,NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY;
uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE;
char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096];
char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096],NOTARYADDRS[18][64];
uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
uint32_t ASSETCHAIN_INIT,ASSETCHAINS_CC,KOMODO_STOPAT,KOMODO_DPOWCONFS = 1;
uint32_t ASSETCHAINS_MAGIC = 2387029918;

View File

@@ -22,6 +22,8 @@
#define KOMODO_MAINNET_START 178999
extern NOTARYADDRS[18][64];
//extern const char *notaries_STAKED[][2];
//extern const int num_notaries_STAKED;
@@ -226,8 +228,12 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam
if ( did0 == 0 )
{
n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0));
for (i=0; i<n0; i++)
for (i=0; i<n0; i++) {
decode_hex(elected_pubkeys0[i],33,(char *)Notaries_elected0[i][1]);
pthread_mutex_lock(&komodo_mutex);
pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)Notaries_elected0[i][1]);
pthread_mutex_unlock(&komodo_mutex);
}
did0 = 1;
}
memcpy(pubkeys,elected_pubkeys0,n0 * 33);
@@ -240,8 +246,12 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam
if ( did1 == 0 )
{
n1 = (int32_t)(sizeof(Notaries_elected1)/sizeof(*Notaries_elected1));
for (i=0; i<n1; i++)
for (i=0; i<n1; i++) {
decode_hex(elected_pubkeys1[i],33,(char *)Notaries_elected1[i][1]);
pthread_mutex_lock(&komodo_mutex);
pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)Notaries_elected1[i][1]);
pthread_mutex_unlock(&komodo_mutex);
}
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
fprintf(stderr,"%s height.%d t.%u elected.%d notaries2\n",ASSETCHAINS_SYMBOL,height,timestamp,n1);
did1 = 1;
@@ -261,8 +271,12 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam
if (didstaked1 == 0)
{
ns1 = num_notaries_STAKED1;
for (i=0; i<ns1; i++)
for (i=0; i<ns1; i++) {
decode_hex(staked_pubkeys1[i],33,(char *)notaries_STAKED1[i][1]);
pthread_mutex_lock(&komodo_mutex);
pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED1[i][1]);
pthread_mutex_unlock(&komodo_mutex);
}
didstaked1 = 1;
didstaked2 = 0;
didstaked3 = 0;
@@ -276,8 +290,12 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam
if (didstaked2 == 0)
{
ns2 = num_notaries_STAKED2;
for (i=0; i<ns2; i++)
for (i=0; i<ns2; i++) {
decode_hex(staked_pubkeys2[i],33,(char *)notaries_STAKED2[i][1]);
pthread_mutex_lock(&komodo_mutex);
pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED2[i][1]);
pthread_mutex_unlock(&komodo_mutex);
}
didstaked2 = 1;
didstaked3 = 0;
didstaked4 = 0;
@@ -290,8 +308,12 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam
if (didstaked3 == 0)
{
ns3 = num_notaries_STAKED3;
for (i=0; i<ns3; i++)
for (i=0; i<ns3; i++) {
decode_hex(staked_pubkeys3[i],33,(char *)notaries_STAKED3[i][1]);
pthread_mutex_lock(&komodo_mutex);
pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED3[i][1]);
pthread_mutex_unlock(&komodo_mutex);
}
didstaked3 = 1;
didstaked4 = 0;
printf("%s IS A STAKED CHAIN and is era 3 \n",ASSETCHAINS_SYMBOL);
@@ -303,8 +325,12 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam
if (didstaked4 == 0)
{
ns4 = num_notaries_STAKED4;
for (i=0; i<ns4; i++)
for (i=0; i<ns4; i++) {
decode_hex(staked_pubkeys4[i],33,(char *)notaries_STAKED4[i][1]);
pthread_mutex_lock(&komodo_mutex);
pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)notaries_STAKED4[i][1]);
pthread_mutex_unlock(&komodo_mutex);
}
didstaked4 = 1;
printf("%s IS A STAKED CHAIN and is era 4 \n",ASSETCHAINS_SYMBOL);
}
@@ -313,8 +339,6 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam
} else if (staked_era == 0)
{
// this means we are in a gap, so we set the array of pubkeys to zero, this does't seem to correctly work, so added exeption to komodo.h aswell.
//for (i=0; i<1; i++)
// decode_hex(null_pubkeys[i],33,(char *)notaries_STAKED1[i][1]);
printf("%s IS A STAKED CHAIN and is in an ERA GAP.\n",ASSETCHAINS_SYMBOL);
memcpy(pubkeys,null_pubkeys,64 * 33);
return(64);

View File

@@ -1044,10 +1044,11 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state,
return true;
}
}
extern NOTARYADDRS[18][64];
int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only
{
static int32_t didinit; static char notaryaddrs[17 + 1][64];
/*static int32_t didinit;
int32_t i;
if ( didinit == 0 )
{
@@ -1060,9 +1061,9 @@ int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only
pubkey2addr((char *)notaryaddrs[i],(uint8_t *)pubkey33);
}
didinit = 1;
}
for (i=0; i<=17; i++)
if ( strcmp(coinaddr,notaryaddrs[i]) == 0 )
} */
for (i=0; i<=64; i++)
if ( strcmp(coinaddr,NOTARYADDRS[i]) == 0 )
return(1);
return(0);
}

View File

@@ -125,9 +125,44 @@ int STAKED_era(int timestamp)
else
era = 0;
// if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP.
if ( era > STAKED_ERA )
STAKED_ERA = era;
return(era);
};
extern NOTARYADDRS[18][64];
int8_t StakedNotaryID(std::string &notaryname, char *Raddress) {
int8_t notaryID = -1;
if ( STAKED_ERA != 0 ) {
switch (STAKED_ERA) {
case 1:
notaryID = ScanStakedArray(notaries_STAKED1,num_notaries_STAKED1,Raddress,notaryname);
break;
case 2:
notaryID = ScanStakedArray(notaries_STAKED2,num_notaries_STAKED2,Raddress,notaryname);
break;
case 3:
notaryID = ScanStakedArray(notaries_STAKED3,num_notaries_STAKED3,Raddress,notaryname);
break;
case 4:
notaryID = ScanStakedArray(notaries_STAKED4,num_notaries_STAKED4,Raddress,notaryname);
break;
}
}
return(notaryID);
}
int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string &notaryname) {
for (size_t i = 0; i < num_notaries; i++) {
if ( strcmp(Raddress,NOTARYADDRS[i]) == 0 ) {
notaryname.assign(notaries_chosen[i][0]);
return(i);
}
}
return(-1)
}
CrosschainAuthority Choose_auth_STAKED(int chosen_era) {
CrosschainAuthority auth;
switch (chosen_era) {

View File

@@ -25,6 +25,8 @@ extern int num_notaries_STAKED4;
int is_STAKED(const char *chain_name);
int STAKED_era(int timestamp);
int8_t StakedNotaryID(std::string &notaryname, char *Raddress);
int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string &notaryname);
CrosschainAuthority Choose_auth_STAKED(int chosen_era);
CrosschainAuthority auth_STAKED_chosen(const char *notaries_chosen[][2],int num_notaries);

View File

@@ -1202,17 +1202,9 @@ bool CWallet::UpdatedNoteData(const CWalletTx& wtxIn, CWalletTx& wtx)
*/
extern uint8_t NOTARY_PUBKEY33[33];
extern std::string NOTARY_ADDRESS;
bool pubkey2addr(char destaddr,uint8_t *pubkey33);
bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate)
{
static bool didNA;
if ( didNA == false && NOTARY_PUBKEY33[0] != 0 && NOTARY_ADDRESS.empty() ) {
char Raddress[18];
pubkey2addr((char *)Raddress,(uint8_t *)NOTARY_PUBKEY33);
NOTARY_ADDRESS.assign(Raddress);
didNA == true;
}
{
AssertLockHeld(cs_wallet);
bool fExisted = mapWallet.count(tx.GetHash()) != 0;
@@ -1226,9 +1218,9 @@ bool CWallet::AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pbl
int numvinIsOurs = 0, numvoutIsOurs = 0; int64_t totalvoutvalue = 0;
for (size_t i = 0; i < tx.vin.size(); i++) {
uint256 hash; CTransaction txin; CTxDestination address;
if (GetTransaction(tx.vin[0].prevout.hash,txin,hash,false))
if (GetTransaction(tx.vin[i].prevout.hash,txin,hash,false))
{
if (ExtractDestination(txin.vout[tx.vin[0].prevout.n].scriptPubKey, address)) {
if (ExtractDestination(txin.vout[tx.vin[i].prevout.n].scriptPubKey, address)) {
// This means we sent the tx..
if ( CBitcoinAddress(address).ToString() == NOTARY_ADDRESS ) {
numvinIsOurs++;
@@ -1259,7 +1251,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 and do nothing else.
// 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.
fprintf(stderr, "There are vins that are not ours, notarisation?\n");
}
}