mirror of
https://git.hush.is/hush/hush3.git
synced 2025-07-27 00:02:08 -04:00
Compare commits
7 Commits
197903c69a
...
497ace0922
Author | SHA1 | Date | |
---|---|---|---|
|
497ace0922 | ||
|
943ffbc1bf | ||
|
d8840beb3b | ||
|
0f5e291f9f | ||
|
77ab75c01d | ||
|
4b7f94effa | ||
|
43aa4a7d90 |
@ -1617,28 +1617,12 @@ void GetHushEarlytxidScriptPub()
|
|||||||
|
|
||||||
int64_t hush_checkcommission(CBlock *pblock,int32_t height)
|
int64_t hush_checkcommission(CBlock *pblock,int32_t height)
|
||||||
{
|
{
|
||||||
|
if(fDebug)
|
||||||
|
fprintf(stderr,"%s at height=%d\n",__func__,height);
|
||||||
int64_t checktoshis=0; uint8_t *script,scripthex[8192]; int32_t scriptlen,matched = 0; static bool didinit = false;
|
int64_t checktoshis=0; uint8_t *script,scripthex[8192]; int32_t scriptlen,matched = 0; static bool didinit = false;
|
||||||
//if(fDebug)
|
|
||||||
|
|
||||||
if ( ASSETCHAINS_SCRIPTPUB.size() > 1 )
|
// Create a local variable instead of modifying the global ASSETCHAINS_SCRIPTPUB
|
||||||
{
|
auto assetchains_scriptpub = devtax_scriptpub_for_height(height);
|
||||||
int32_t i;
|
|
||||||
fprintf(stderr,"%s: height=%d ASSETCHAINS_SCRIPTPUB=",__func__,height);
|
|
||||||
for (i=0; i<ASSETCHAINS_SCRIPTPUB.size(); i++) {
|
|
||||||
fprintf(stderr,"%02x",ASSETCHAINS_SCRIPTPUB[i]);
|
|
||||||
}
|
|
||||||
fprintf(stderr," size=%li\n", ASSETCHAINS_SCRIPTPUB.size());
|
|
||||||
}
|
|
||||||
ASSETCHAINS_SCRIPTPUB = devtax_scriptpub_for_height(height);
|
|
||||||
if ( ASSETCHAINS_SCRIPTPUB.size() > 1 )
|
|
||||||
{
|
|
||||||
int32_t i;
|
|
||||||
fprintf(stderr,"%s: devtax_scriptpub_for_height(%d)=",__func__,height);
|
|
||||||
for (i=0; i<ASSETCHAINS_SCRIPTPUB.size(); i++) {
|
|
||||||
fprintf(stderr,"%02x",ASSETCHAINS_SCRIPTPUB[i]);
|
|
||||||
}
|
|
||||||
fprintf(stderr," size=%li\n", ASSETCHAINS_SCRIPTPUB.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 )
|
if ( ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0 )
|
||||||
{
|
{
|
||||||
@ -1652,32 +1636,29 @@ int64_t hush_checkcommission(CBlock *pblock,int32_t height)
|
|||||||
{
|
{
|
||||||
script = (uint8_t *)&pblock->vtx[0].vout[1].scriptPubKey[0];
|
script = (uint8_t *)&pblock->vtx[0].vout[1].scriptPubKey[0];
|
||||||
scriptlen = (int32_t)pblock->vtx[0].vout[1].scriptPubKey.size();
|
scriptlen = (int32_t)pblock->vtx[0].vout[1].scriptPubKey.size();
|
||||||
if ( 1 ) // fDebug )
|
if ( fDebug )
|
||||||
{
|
{
|
||||||
int32_t i;
|
int32_t i;
|
||||||
fprintf(stderr, "%s: script=", __func__);
|
|
||||||
for (i=0; i<scriptlen; i++)
|
for (i=0; i<scriptlen; i++)
|
||||||
fprintf(stderr,"%02x",script[i]);
|
fprintf(stderr,"%02x",script[i]);
|
||||||
// fprintf(stderr," vout[1] %.8f vs %.8f\n",(double)checktoshis/COIN,(double)pblock->vtx[0].vout[1].nValue/COIN);
|
fprintf(stderr," vout[1] %.8f vs %.8f\n",(double)checktoshis/COIN,(double)pblock->vtx[0].vout[1].nValue/COIN);
|
||||||
fprintf(stderr," scriptlen=%d\n", scriptlen);
|
|
||||||
}
|
}
|
||||||
if ( ASSETCHAINS_SCRIPTPUB.size() > 1 )
|
if ( assetchains_scriptpub.size() > 1 )
|
||||||
{
|
{
|
||||||
static bool didinit = false;
|
static bool didinit = false;
|
||||||
if ( !didinit && height > HUSH_EARLYTXID_HEIGHT && HUSH_EARLYTXID != zeroid && hush_appendACscriptpub() )
|
if ( !didinit && height > HUSH_EARLYTXID_HEIGHT && HUSH_EARLYTXID != zeroid && hush_appendACscriptpub() )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "appended CC_op_return to ASSETCHAINS_SCRIPTPUB.%s\n", ASSETCHAINS_SCRIPTPUB.c_str());
|
fprintf(stderr, "appended CC_op_return to assetchains_scriptpub.%s\n", assetchains_scriptpub.c_str());
|
||||||
didinit = true;
|
didinit = true;
|
||||||
}
|
}
|
||||||
if ( ASSETCHAINS_SCRIPTPUB.size()/2 == scriptlen && scriptlen < sizeof(scripthex) )
|
if ( assetchains_scriptpub.size()/2 == scriptlen && scriptlen < sizeof(scripthex) )
|
||||||
{
|
{
|
||||||
decode_hex(scripthex,scriptlen,(char *)ASSETCHAINS_SCRIPTPUB.c_str());
|
decode_hex(scripthex,scriptlen,(char *)assetchains_scriptpub.c_str());
|
||||||
if ( memcmp(scripthex,script,scriptlen) == 0 )
|
if ( memcmp(scripthex,script,scriptlen) == 0 ) {
|
||||||
matched = scriptlen;
|
matched = scriptlen;
|
||||||
else
|
|
||||||
fprintf(stderr,"%s: ASSETCHAINS_SCRIPTPUB != script\n", __func__);
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,"%s: ASSETCHAINS_SCRIPTPUB is incorrect size! scriptlen=%d sizeof(scriptlen)=%li\n", __func__, scriptlen, sizeof(scripthex) );
|
fprintf(stderr, "%s: assetchains_scriptpub != scripthex scriptlen=%d\n", __func__, scriptlen);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) == 0 )
|
else if ( scriptlen == 35 && script[0] == 33 && script[34] == OP_CHECKSIG && memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) == 0 )
|
||||||
@ -1686,19 +1667,19 @@ int64_t hush_checkcommission(CBlock *pblock,int32_t height)
|
|||||||
matched = 25;
|
matched = 25;
|
||||||
if ( matched == 0 )
|
if ( matched == 0 )
|
||||||
{
|
{
|
||||||
if ( ASSETCHAINS_SCRIPTPUB.size() > 1 )
|
if ( assetchains_scriptpub.size() > 1 )
|
||||||
{
|
{
|
||||||
int32_t i;
|
int32_t i;
|
||||||
fprintf(stderr,"%s: ASSETCHAINS_SCRIPTPUB=", __func__);
|
fprintf(stderr,"%s: assetchains_scriptpub=", __func__);
|
||||||
for (i=0; i<ASSETCHAINS_SCRIPTPUB.size(); i++) {
|
for (i=0; i<assetchains_scriptpub.size(); i++) {
|
||||||
fprintf(stderr,"%02x",ASSETCHAINS_SCRIPTPUB[i]);
|
fprintf(stderr,"%02x",assetchains_scriptpub[i]);
|
||||||
}
|
}
|
||||||
fprintf(stderr," vs script=");
|
fprintf(stderr," vs script=");
|
||||||
for (i=0; i<scriptlen; i++) {
|
for (i=0; i<scriptlen; i++) {
|
||||||
fprintf(stderr,"%02x",script[i]);
|
fprintf(stderr,"%02x",script[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fprintf(stderr," -ac[%d] payment to wrong pubkey scriptlen.%d, scriptpub[%d] checktoshis.%llu\n",(int32_t)ASSETCHAINS_SCRIPTPUB.size(),scriptlen,(int32_t)ASSETCHAINS_SCRIPTPUB.size()/2,(long long)checktoshis);
|
fprintf(stderr," -ac[%d] payment to wrong pubkey scriptlen.%d, scriptpub[%d] checktoshis.%llu\n",(int32_t)assetchains_scriptpub.size(),scriptlen,(int32_t)assetchains_scriptpub.size()/2,(long long)checktoshis);
|
||||||
return(-1);
|
return(-1);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -1754,13 +1735,14 @@ int32_t hush_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
|
|||||||
}
|
}
|
||||||
if ( failed == 0 && ASSETCHAINS_COMMISSION != 0 ) {
|
if ( failed == 0 && ASSETCHAINS_COMMISSION != 0 ) {
|
||||||
if ( height == 1 ) {
|
if ( height == 1 ) {
|
||||||
ASSETCHAINS_SCRIPTPUB = devtax_scriptpub_for_height(height);
|
// Create a local variable instead of modifying the global assetchains_scriptpub
|
||||||
if ( ASSETCHAINS_SCRIPTPUB.size() > 1 && ASSETCHAINS_SCRIPTPUB[ASSETCHAINS_SCRIPTPUB.back()] != 49 && ASSETCHAINS_SCRIPTPUB[ASSETCHAINS_SCRIPTPUB.back()-1] != 51 ) {
|
auto assetchains_scriptpub = devtax_scriptpub_for_height(height);
|
||||||
|
if ( assetchains_scriptpub.size() > 1 && assetchains_scriptpub[assetchains_scriptpub.back()] != 49 && assetchains_scriptpub[assetchains_scriptpub.back()-1] != 51 ) {
|
||||||
int32_t scriptlen; uint8_t scripthex[10000];
|
int32_t scriptlen; uint8_t scripthex[10000];
|
||||||
script = (uint8_t *)&pblock->vtx[0].vout[0].scriptPubKey[0];
|
script = (uint8_t *)&pblock->vtx[0].vout[0].scriptPubKey[0];
|
||||||
scriptlen = (int32_t)pblock->vtx[0].vout[0].scriptPubKey.size();
|
scriptlen = (int32_t)pblock->vtx[0].vout[0].scriptPubKey.size();
|
||||||
if ( ASSETCHAINS_SCRIPTPUB.size()/2 == scriptlen && scriptlen < sizeof(scripthex) ) {
|
if ( assetchains_scriptpub.size()/2 == scriptlen && scriptlen < sizeof(scripthex) ) {
|
||||||
decode_hex(scripthex,scriptlen,(char *)ASSETCHAINS_SCRIPTPUB.c_str());
|
decode_hex(scripthex,scriptlen,(char *)assetchains_scriptpub.c_str());
|
||||||
if ( memcmp(scripthex,script,scriptlen) != 0 )
|
if ( memcmp(scripthex,script,scriptlen) != 0 )
|
||||||
return(-1);
|
return(-1);
|
||||||
} else return(-1);
|
} else return(-1);
|
||||||
|
@ -868,7 +868,7 @@ unsigned char _decode_hex(char *hex) { return((unhex(hex[0])<<4) | unhex(hex[1])
|
|||||||
int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex)
|
int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex)
|
||||||
{
|
{
|
||||||
int32_t adjust,i = 0;
|
int32_t adjust,i = 0;
|
||||||
fprintf(stderr,"%s(%s) n=%d\n",__func__, hex, n);
|
//printf("decode.(%s)\n",hex);
|
||||||
if ( is_hexstr(hex,n) <= 0 )
|
if ( is_hexstr(hex,n) <= 0 )
|
||||||
{
|
{
|
||||||
memset(bytes,0,n);
|
memset(bytes,0,n);
|
||||||
|
@ -660,27 +660,29 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
|||||||
|
|
||||||
pblock->vtx[0] = txNew;
|
pblock->vtx[0] = txNew;
|
||||||
|
|
||||||
ASSETCHAINS_SCRIPTPUB = devtax_scriptpub_for_height(nHeight);
|
// Create a local variable instead of modifying the global ASSETCHAINS_SCRIPTPUB
|
||||||
if ( nHeight > 1 && SMART_CHAIN_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1) && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0) && (commission= the_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0 )
|
auto assetchains_scriptpub = devtax_scriptpub_for_height(nHeight);
|
||||||
|
|
||||||
|
if ( nHeight > 1 && SMART_CHAIN_SYMBOL[0] != 0 && (ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 || assetchains_scriptpub.size() > 1) && (ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_FOUNDERS_REWARD != 0) && (commission= the_commission((CBlock*)&pblocktemplate->block,(int32_t)nHeight)) != 0 )
|
||||||
{
|
{
|
||||||
int32_t i; uint8_t *ptr;
|
int32_t i; uint8_t *ptr;
|
||||||
txNew.vout.resize(2);
|
txNew.vout.resize(2);
|
||||||
txNew.vout[1].nValue = commission;
|
txNew.vout[1].nValue = commission;
|
||||||
if ( ASSETCHAINS_SCRIPTPUB.size() > 1 )
|
if ( assetchains_scriptpub.size() > 1 )
|
||||||
{
|
{
|
||||||
static bool didinit = false;
|
static bool didinit = false;
|
||||||
if ( !didinit && nHeight > HUSH_EARLYTXID_HEIGHT && HUSH_EARLYTXID != zeroid && hush_appendACscriptpub() )
|
if ( !didinit && nHeight > HUSH_EARLYTXID_HEIGHT && HUSH_EARLYTXID != zeroid && hush_appendACscriptpub() )
|
||||||
{
|
{
|
||||||
fprintf(stderr, "appended ccopreturn to ASSETCHAINS_SCRIPTPUB.%s\n", ASSETCHAINS_SCRIPTPUB.c_str());
|
fprintf(stderr, "appended ccopreturn to assetchains_scriptpub.%s\n", assetchains_scriptpub.c_str());
|
||||||
didinit = true;
|
didinit = true;
|
||||||
}
|
}
|
||||||
//fprintf(stderr,"mine to -ac_script\n");
|
//fprintf(stderr,"mine to -ac_script\n");
|
||||||
//txNew.vout[1].scriptPubKey = CScript() << ParseHex();
|
//txNew.vout[1].scriptPubKey = CScript() << ParseHex();
|
||||||
int32_t len = strlen(ASSETCHAINS_SCRIPTPUB.c_str());
|
int32_t len = strlen(assetchains_scriptpub.c_str());
|
||||||
len >>= 1;
|
len >>= 1;
|
||||||
txNew.vout[1].scriptPubKey.resize(len);
|
txNew.vout[1].scriptPubKey.resize(len);
|
||||||
ptr = (uint8_t *)&txNew.vout[1].scriptPubKey[0];
|
ptr = (uint8_t *)&txNew.vout[1].scriptPubKey[0];
|
||||||
decode_hex(ptr,len,(char *)ASSETCHAINS_SCRIPTPUB.c_str());
|
decode_hex(ptr,len,(char *)assetchains_scriptpub.c_str());
|
||||||
} else {
|
} else {
|
||||||
txNew.vout[1].scriptPubKey.resize(35);
|
txNew.vout[1].scriptPubKey.resize(35);
|
||||||
ptr = (uint8_t *)&txNew.vout[1].scriptPubKey[0];
|
ptr = (uint8_t *)&txNew.vout[1].scriptPubKey[0];
|
||||||
@ -850,8 +852,10 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight,
|
|||||||
{
|
{
|
||||||
CPubKey pubkey; CScript scriptPubKey; uint8_t *script,*ptr; int32_t i,len;
|
CPubKey pubkey; CScript scriptPubKey; uint8_t *script,*ptr; int32_t i,len;
|
||||||
// fprintf(stderr,"%s: with nHeight=%d\n", __func__, nHeight);
|
// fprintf(stderr,"%s: with nHeight=%d\n", __func__, nHeight);
|
||||||
ASSETCHAINS_SCRIPTPUB = devtax_scriptpub_for_height(nHeight);
|
|
||||||
if ( nHeight == 1 && ASSETCHAINS_COMMISSION != 0 && ASSETCHAINS_SCRIPTPUB[ASSETCHAINS_SCRIPTPUB.back()] != 49 && ASSETCHAINS_SCRIPTPUB[ASSETCHAINS_SCRIPTPUB.back()-1] != 51 )
|
// Create a local variable instead of modifying the global assetchains_scriptpub
|
||||||
|
auto assetchains_scriptpub = devtax_scriptpub_for_height(nHeight);
|
||||||
|
if ( nHeight == 1 && ASSETCHAINS_COMMISSION != 0 && assetchains_scriptpub[assetchains_scriptpub.back()] != 49 && assetchains_scriptpub[assetchains_scriptpub.back()-1] != 51 )
|
||||||
{
|
{
|
||||||
if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 )
|
if ( ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 )
|
||||||
{
|
{
|
||||||
@ -859,11 +863,11 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey, int32_t nHeight,
|
|||||||
scriptPubKey = CScript() << ParseHex(HexStr(pubkey)) << OP_CHECKSIG;
|
scriptPubKey = CScript() << ParseHex(HexStr(pubkey)) << OP_CHECKSIG;
|
||||||
// fprintf(stderr,"%s: with pubkey=%s\n", __func__, HexStr(pubkey).c_str() );
|
// fprintf(stderr,"%s: with pubkey=%s\n", __func__, HexStr(pubkey).c_str() );
|
||||||
} else {
|
} else {
|
||||||
len = strlen(ASSETCHAINS_SCRIPTPUB.c_str());
|
len = strlen(assetchains_scriptpub.c_str());
|
||||||
len >>= 1;
|
len >>= 1;
|
||||||
scriptPubKey.resize(len);
|
scriptPubKey.resize(len);
|
||||||
ptr = (uint8_t *)&scriptPubKey[0];
|
ptr = (uint8_t *)&scriptPubKey[0];
|
||||||
decode_hex(ptr,len,(char *)ASSETCHAINS_SCRIPTPUB.c_str());
|
decode_hex(ptr,len,(char *)assetchains_scriptpub.c_str());
|
||||||
}
|
}
|
||||||
} else if ( USE_EXTERNAL_PUBKEY != 0 ) {
|
} else if ( USE_EXTERNAL_PUBKEY != 0 ) {
|
||||||
//fprintf(stderr,"use notary pubkey\n");
|
//fprintf(stderr,"use notary pubkey\n");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user