Support for notarizing PRIVATE
This commit is contained in:
@@ -197,6 +197,7 @@ const char *Notaries_elected1[][2] =
|
|||||||
{"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" },
|
{"webworker01_NA", "03bb7d005e052779b1586f071834c5facbb83470094cff5112f0072b64989f97d7" },
|
||||||
{"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" },
|
{"xrobesx_NA", "03f0cc6d142d14a40937f12dbd99dbd9021328f45759e26f1877f2a838876709e1" },
|
||||||
};
|
};
|
||||||
|
#define CRYPTO777_PUBSECPSTR "020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9"
|
||||||
|
|
||||||
int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp)
|
int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp)
|
||||||
{
|
{
|
||||||
|
|||||||
44
src/main.cpp
44
src/main.cpp
@@ -60,6 +60,8 @@ extern int32_t KOMODO_LOADINGBLOCKS,KOMODO_LONGESTCHAIN,KOMODO_INSYNC,KOMODO_CON
|
|||||||
int32_t KOMODO_NEWBLOCKS;
|
int32_t KOMODO_NEWBLOCKS;
|
||||||
int32_t komodo_block2pubkey33(uint8_t *pubkey33,CBlock *block);
|
int32_t komodo_block2pubkey33(uint8_t *pubkey33,CBlock *block);
|
||||||
void komodo_broadcast(CBlock *pblock,int32_t limit);
|
void komodo_broadcast(CBlock *pblock,int32_t limit);
|
||||||
|
void komodo_broadcast(CBlock *pblock,int32_t limit);
|
||||||
|
bool Getscriptaddress(char *destaddr,const CScript &scriptPubKey);
|
||||||
|
|
||||||
BlockMap mapBlockIndex;
|
BlockMap mapBlockIndex;
|
||||||
CChain chainActive;
|
CChain chainActive;
|
||||||
@@ -1036,6 +1038,28 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t komodo_isnotaryvout(char *coinaddr) // from ac_private chains only
|
||||||
|
{
|
||||||
|
static int32_t didinit; static char notaryaddrs[sizeof(Notaries_elected1)/sizeof(*Notaries_elected1) + 1][64];
|
||||||
|
int32_t i;
|
||||||
|
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);
|
||||||
|
pubkey2addr((char *)notaryaddrs[i],(uint8_t *)pubkey33);
|
||||||
|
}
|
||||||
|
didinit = 1;
|
||||||
|
}
|
||||||
|
for (i=0; i<=sizeof(Notaries_elected1)/sizeof(*Notaries_elected1); i++)
|
||||||
|
if ( strcmp(coinaddr,notaryaddrs[i]) == 0 )
|
||||||
|
return(1);
|
||||||
|
return(0);
|
||||||
|
}
|
||||||
|
|
||||||
bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidationState &state)
|
bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidationState &state)
|
||||||
{
|
{
|
||||||
// Basic checks that don't depend on any context
|
// Basic checks that don't depend on any context
|
||||||
@@ -1112,10 +1136,15 @@ bool CheckTransactionWithoutProofVerification(const CTransaction& tx, CValidatio
|
|||||||
}
|
}
|
||||||
if ( ASSETCHAINS_PRIVATE != 0 )
|
if ( ASSETCHAINS_PRIVATE != 0 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"private chain nValue %.8f iscoinbase.%d\n",(double)txout.nValue/COIN,iscoinbase);
|
//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.nValue > 0 && iscoinbase == 0) || tx.GetJoinSplitValueOut() > 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");
|
return state.DoS(100, error("CheckTransaction(): this is a private chain, no public allowed"),REJECT_INVALID, "bad-txns-acprivacy-chain");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if ( txout.scriptPubKey.size() > IGUANA_MAXSCRIPTSIZE )
|
if ( txout.scriptPubKey.size() > IGUANA_MAXSCRIPTSIZE )
|
||||||
return state.DoS(100, error("CheckTransaction(): txout.scriptPubKey.size() too big"),REJECT_INVALID, "bad-txns-vout-negative");
|
return state.DoS(100, error("CheckTransaction(): txout.scriptPubKey.size() too big"),REJECT_INVALID, "bad-txns-vout-negative");
|
||||||
nValueOut += txout.nValue;
|
nValueOut += txout.nValue;
|
||||||
@@ -3621,7 +3650,17 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
|
|||||||
// our genesis block. In practice this (probably) won't happen because of checks elsewhere.
|
// our genesis block. In practice this (probably) won't happen because of checks elsewhere.
|
||||||
auto reorgLength = pindexOldTip ? pindexOldTip->nHeight - (pindexFork ? pindexFork->nHeight : -1) : 0;
|
auto reorgLength = pindexOldTip ? pindexOldTip->nHeight - (pindexFork ? pindexFork->nHeight : -1) : 0;
|
||||||
static_assert(MAX_REORG_LENGTH > 0, "We must be able to reorg some distance");
|
static_assert(MAX_REORG_LENGTH > 0, "We must be able to reorg some distance");
|
||||||
if (reorgLength > MAX_REORG_LENGTH) {
|
if (reorgLength > MAX_REORG_LENGTH)
|
||||||
|
{
|
||||||
|
int32_t notarizedht,prevMoMheight; uint256 notarizedhash,txid;
|
||||||
|
notarizedht = komodo_notarized_height(&prevMoMheight,¬arizedhash,&txid);
|
||||||
|
if ( pindexFork->nHeight < notarizedht )
|
||||||
|
{
|
||||||
|
fprintf(stderr,"pindexFork->nHeight.%d is < notarizedht %d, so ignore it\n",(int32_t)pindexFork->nHeight,notarizedht);
|
||||||
|
pindexFork = pindexOldTip;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
auto msg = strprintf(_(
|
auto msg = strprintf(_(
|
||||||
"A block chain reorganization has been detected that would roll back %d blocks! "
|
"A block chain reorganization has been detected that would roll back %d blocks! "
|
||||||
"This is larger than the maximum of %d blocks, and so the node is shutting down for your safety."
|
"This is larger than the maximum of %d blocks, and so the node is shutting down for your safety."
|
||||||
@@ -3639,6 +3678,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo
|
|||||||
StartShutdown();
|
StartShutdown();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Disconnect active blocks which are no longer in the best chain.
|
// Disconnect active blocks which are no longer in the best chain.
|
||||||
bool fBlocksDisconnected = false;
|
bool fBlocksDisconnected = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user