Sane -ac_perc
This commit is contained in:
@@ -650,6 +650,22 @@ int32_t komodo_bannedset(int32_t *indallvoutsp,uint256 *array,int32_t max)
|
|||||||
|
|
||||||
void komodo_passport_iteration();
|
void komodo_passport_iteration();
|
||||||
|
|
||||||
|
uint64_t komodo_commission(const CBlock &block)
|
||||||
|
{
|
||||||
|
int32_t i,j,n,txn_count; uint64_t total = 0;
|
||||||
|
txn_count = block.vtx.size();
|
||||||
|
for (i=0; i<txn_count; i++)
|
||||||
|
{
|
||||||
|
n = block.vtx[i].vout.size();
|
||||||
|
for (j=0; j<n; j++)
|
||||||
|
{
|
||||||
|
if ( i != 0 || j != 1 )
|
||||||
|
total += block.vtx[i].vout[j].nValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return((total * ASSETCHAINS_COMMISSION) / COIN);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing
|
int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing
|
||||||
{
|
{
|
||||||
static uint256 array[64]; static int32_t numbanned,indallvouts;
|
static uint256 array[64]; static int32_t numbanned,indallvouts;
|
||||||
@@ -725,26 +741,21 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
|
|||||||
}
|
}
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
/*if ( ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_COMMISSION != 0 )
|
if ( ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 && block.vtx[0].size() > 1 )
|
||||||
{
|
{
|
||||||
script = (uint8_t *)block.vtx[0].vout[0].scriptPubKey.data();
|
script = (uint8_t *)block.vtx[0].vout[1].scriptPubKey.data();
|
||||||
if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 )
|
if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 )
|
||||||
return(-1);
|
return(-1);
|
||||||
total = 0;
|
if ( (checktoshis = komodo_commission(block)) != 0 )
|
||||||
for (i=1; i<txn_count; i++)
|
|
||||||
{
|
{
|
||||||
n = block.vtx[i].vout.size();
|
if ( block.vtx[0].vout.size() < 2 || block.vtx[0].vout[1].nValue != checktoshis )
|
||||||
for (j=0; j<n; j++)
|
{
|
||||||
total += block.vtx[i].vout[j].nValue;
|
fprintf(stderr,"checktoshis %.8f vs actual vout[1] %.8f\n",dstr(checktoshis),dstr(block.vtx[0].vout[1].nValue));
|
||||||
}
|
|
||||||
if ( (checktoshis = (total * ASSETCHAINS_COMMISSION) / COIN) != 0 )
|
|
||||||
{
|
|
||||||
subsidy = GetBlockSubsidy(height,Params().GetConsensus());
|
|
||||||
if ( block.vtx[0].vout.size() != 1 || block.vtx[0].vout[0].nValue != checktoshis+subsidy )
|
|
||||||
return(-1);
|
return(-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
//fprintf(stderr,"ht.%d n.%d nValue %.8f (%d %d %d)\n",height,n,dstr(block.vtx[0].vout[1].nValue),KOMODO_PAX,komodo_isrealtime(&ht),KOMODO_PASSPORT_INITDONE);
|
//fprintf(stderr,"ht.%d n.%d nValue %.8f (%d %d %d)\n",height,n,dstr(block.vtx[0].vout[1].nValue),KOMODO_PAX,komodo_isrealtime(&ht),KOMODO_PASSPORT_INITDONE);
|
||||||
offset += komodo_scriptitemlen(&opretlen,&script[offset]);
|
offset += komodo_scriptitemlen(&opretlen,&script[offset]);
|
||||||
//printf("offset.%d opretlen.%d [%02x %02x %02x %02x]\n",offset,opretlen,script[0],script[1],script[2],script[3]);
|
//printf("offset.%d opretlen.%d [%02x %02x %02x %02x]\n",offset,opretlen,script[0],script[1],script[2],script[3]);
|
||||||
|
|||||||
@@ -119,6 +119,7 @@ int32_t komodo_is_issuer();
|
|||||||
int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *symbol,int32_t tokomodo);
|
int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *symbol,int32_t tokomodo);
|
||||||
int32_t komodo_isrealtime(int32_t *kmdheightp);
|
int32_t komodo_isrealtime(int32_t *kmdheightp);
|
||||||
int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_t nTime,int32_t dispflag);
|
int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_t nTime,int32_t dispflag);
|
||||||
|
uint64_t komodo_commission(const CBlock &block);
|
||||||
|
|
||||||
CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||||
{
|
{
|
||||||
@@ -395,6 +396,18 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
|||||||
// Add fees
|
// Add fees
|
||||||
txNew.vout[0].nValue += nFees;
|
txNew.vout[0].nValue += nFees;
|
||||||
txNew.vin[0].scriptSig = CScript() << nHeight << OP_0;
|
txNew.vin[0].scriptSig = CScript() << nHeight << OP_0;
|
||||||
|
if ( ASSETCHAINS_SYMBOL[0] != 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 && ASSETCHAINS_COMMISSION != 0 && (checktoshis= komodo_commission(block)) != 0 )
|
||||||
|
{
|
||||||
|
txNew.vout.resize(2);
|
||||||
|
txNew.vout[1].nValue = checktoshis;
|
||||||
|
txNew.vout[1].scriptPubKey.resize(35);
|
||||||
|
ptr = (uint8_t *)txNew.vout[1].scriptPubKey.data();
|
||||||
|
ptr[0] = 33;
|
||||||
|
for (i=0; i<33; i++)
|
||||||
|
ptr[i+1] = ASSETCHAINS_OVERRIDE_PUBKEY33[i];
|
||||||
|
ptr[34] = OP_CHECKSIG;
|
||||||
|
}
|
||||||
|
|
||||||
/*if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
/*if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
||||||
{
|
{
|
||||||
int32_t i,opretlen; uint8_t opret[256],*ptr;
|
int32_t i,opretlen; uint8_t opret[256],*ptr;
|
||||||
|
|||||||
Reference in New Issue
Block a user