This commit is contained in:
jl777
2018-09-23 05:47:33 -11:00
parent a7e86f3a81
commit 3a36ff1776
4 changed files with 23 additions and 7 deletions

View File

@@ -198,6 +198,14 @@ bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey)
return(false);
}
bool pubkey2addr(char *destaddr,uint8_t *pubkey33)
{
std::vector<uint8_t>pk; int32_t i;
for (i=0; i<33; i++)
pk.push_back(pubkey33[i]);
return(Getscriptaddress(destaddr,CScript() << pk << OP_CHECKSIG));
}
CPubKey CCtxidaddr(char *txidaddr,uint256 txid)
{
uint8_t buf33[33]; CPubKey pk;

View File

@@ -29,6 +29,7 @@ uint64_t komodo_paxtotal();
int32_t komodo_longestchain();
uint64_t komodo_maxallowed(int32_t baseid);
int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max);
bool pubkey2addr(char *destaddr,uint8_t *pubkey33);
pthread_mutex_t komodo_mutex;

View File

@@ -199,20 +199,24 @@ const char *Notaries_elected1[][2] =
};
#define CRYPTO777_PUBSECPSTR "020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9"
int32_t komodo_isnotaryvout(uint8_t *script) // from ac_private chains only
int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only
{
uint8_t pubkey33[33]; int32_t i;
if ( script[0] == 33 && script[34] == 0xac )
static int32_t didinit; static char notaryaddrs[65][64];
if ( didinit == 0 )
{
uint8_t pubkey33[33];
for (i=0; i<=sizeof(Notaries_elected1)/sizeof(*Notaries_elected1); i++)
{
if ( i < sizeof(Notaries_elected1)/sizeof(*Notaries_elected1) )
decode_hex(pubkey33,33,(char *)Notaries_elected1[i][1]);
else decode_hex(pubkey33,33,(char *)CRYPTO777_PUBSECPSTR);
if ( memcmp(script+1,pubkey33,33) == 0 )
return(1);
pubkey2addr(notaryaddrs[i],pubkey33);
}
didinit = 1;
}
for (i=0; i<=sizeof(Notaries_elected1)/sizeof(*Notaries_elected1); i++)
if ( strcmp(coinaddr,notaryaddrs[i]) == 0 )
return(1);
return(0);
}

View File

@@ -60,7 +60,8 @@ extern int32_t KOMODO_LOADINGBLOCKS,KOMODO_LONGESTCHAIN,KOMODO_INSYNC,KOMODO_CON
int32_t KOMODO_NEWBLOCKS;
int32_t komodo_block2pubkey33(uint8_t *pubkey33,CBlock *block);
void komodo_broadcast(CBlock *pblock,int32_t limit);
int32_t komodo_isnotaryvout(CScript scriptPubKey);
int32_t komodo_isnotaryvout(char *destaddr);
bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey);
BlockMap mapBlockIndex;
CChain chainActive;
@@ -1121,7 +1122,9 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio
//fprintf(stderr,"private chain nValue %.8f iscoinbase.%d\n",(double)txout.nValue/COIN,iscoinbase);
if ( (txout.nValue > 0 && iscoinbase == 0) || tx.GetJoinSplitValueOut() > 0 )
{
if ( txout.scriptPubKey.size() == 35 && komodo_isnotaryvout((uint8_t *)txout.scriptPubKey.data()) == 0 )
char destaddr[65];
Getscriptaddress(destaddr,txout.scriptPubKey);
if ( komodo_isnotaryvout(destaddr) == 0 )
return state.DoS(100, error("CheckTransaction(): this is a private chain, no public allowed"),REJECT_INVALID, "bad-txns-acprivacy-chain");
}
}