test
This commit is contained in:
@@ -51,7 +51,7 @@ struct pax_transaction *komodo_paxmark(int32_t height,struct pax_transaction *sp
|
|||||||
return(pax);
|
return(pax);
|
||||||
}
|
}
|
||||||
|
|
||||||
void komodo_gateway_deposit(char *coinaddr,uint64_t value,int32_t shortflag,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,int32_t height,int32_t otherheight) // assetchain context
|
void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,int32_t height,int32_t otherheight) // assetchain context
|
||||||
{
|
{
|
||||||
struct pax_transaction *pax; int32_t addflag = 0; struct komodo_state *sp; char str[16],dest[16];
|
struct pax_transaction *pax; int32_t addflag = 0; struct komodo_state *sp; char str[16],dest[16];
|
||||||
sp = komodo_stateptr(str,dest);
|
sp = komodo_stateptr(str,dest);
|
||||||
@@ -76,7 +76,6 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,int32_t shortflag,char
|
|||||||
{
|
{
|
||||||
strcpy(pax->coinaddr,coinaddr);
|
strcpy(pax->coinaddr,coinaddr);
|
||||||
pax->komodoshis = value;
|
pax->komodoshis = value;
|
||||||
pax->shortflag = shortflag;
|
|
||||||
strcpy(pax->symbol,symbol);
|
strcpy(pax->symbol,symbol);
|
||||||
pax->fiatoshis = fiatoshis;
|
pax->fiatoshis = fiatoshis;
|
||||||
memcpy(pax->rmd160,rmd160,20);
|
memcpy(pax->rmd160,rmd160,20);
|
||||||
@@ -101,7 +100,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,uint8_t
|
|||||||
int32_t i,n=0,j,len;
|
int32_t i,n=0,j,len;
|
||||||
for (i=0; i<4; i++)
|
for (i=0; i<4; i++)
|
||||||
base[i] = opretbuf[opretlen-4+i];
|
base[i] = opretbuf[opretlen-4+i];
|
||||||
if ( ASSETCHAINS_SYMBOL[0] == 0 || strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) // shortflag
|
if ( ASSETCHAINS_SYMBOL[0] == 0 || strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 )
|
||||||
{
|
{
|
||||||
opretbuf++, opretlen--;
|
opretbuf++, opretlen--;
|
||||||
for (n=len=0; n<opretlen/34; n++)
|
for (n=len=0; n<opretlen/34; n++)
|
||||||
@@ -116,13 +115,10 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,uint8_t
|
|||||||
//printf(" issuedtxid v%d i.%d opretlen.%d\n",vouts[n],n,opretlen);
|
//printf(" issuedtxid v%d i.%d opretlen.%d\n",vouts[n],n,opretlen);
|
||||||
if ( iskomodo != 0 )
|
if ( iskomodo != 0 )
|
||||||
{
|
{
|
||||||
uint64_t fiatoshis; int32_t height,otherheight,shortflag; char symbol[16];
|
uint64_t fiatoshis; int32_t height,otherheight; char symbol[16];
|
||||||
len += iguana_rwnum(0,&opretbuf[len],sizeof(fiatoshis),&fiatoshis);
|
len += iguana_rwnum(0,&opretbuf[len],sizeof(fiatoshis),&fiatoshis);
|
||||||
len += iguana_rwnum(0,&opretbuf[len],sizeof(height),&height);
|
len += iguana_rwnum(0,&opretbuf[len],sizeof(height),&height);
|
||||||
len += iguana_rwnum(0,&opretbuf[len],sizeof(otherheight),&otherheight);
|
len += iguana_rwnum(0,&opretbuf[len],sizeof(otherheight),&otherheight);
|
||||||
if ( opretbuf[len] == '-' )
|
|
||||||
shortflag = 1, len++;
|
|
||||||
else shortflag = 0;
|
|
||||||
for (i=0; opretbuf[len+i]!=0&&i<3; i++)
|
for (i=0; opretbuf[len+i]!=0&&i<3; i++)
|
||||||
symbol[i] = opretbuf[len+i];
|
symbol[i] = opretbuf[len+i];
|
||||||
symbol[i] = 0;
|
symbol[i] = 0;
|
||||||
@@ -148,7 +144,7 @@ uint64_t komodo_paxtotal()
|
|||||||
else total += pax->komodoshis;
|
else total += pax->komodoshis;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("paxtotal %.8f\n",dstr(total));
|
//printf("paxtotal %.8f\n",dstr(total));
|
||||||
return(total);
|
return(total);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,10 +163,10 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
|
|||||||
else opcode = 'X';
|
else opcode = 'X';
|
||||||
HASH_ITER(hh,PAX,pax,tmp)
|
HASH_ITER(hh,PAX,pax,tmp)
|
||||||
{
|
{
|
||||||
printf("pax.%s marked.%d %.8f -> %.8f\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis));
|
//printf("pax.%s marked.%d %.8f -> %.8f\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis));
|
||||||
if ( pax->marked != 0 || strcmp(pax->symbol,ASSETCHAINS_SYMBOL) != 0 )
|
if ( pax->marked != 0 || strcmp(pax->symbol,symbol) != 0 )
|
||||||
continue;
|
continue;
|
||||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
//if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||||
printf("pax.%s marked.%d %.8f -> %.8f\n",ASSETCHAINS_SYMBOL,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis));
|
printf("pax.%s marked.%d %.8f -> %.8f\n",ASSETCHAINS_SYMBOL,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis));
|
||||||
txNew->vout.resize(numvouts+1);
|
txNew->vout.resize(numvouts+1);
|
||||||
txNew->vout[numvouts].nValue = (opcode == 'I') ? pax->fiatoshis : pax->komodoshis;
|
txNew->vout[numvouts].nValue = (opcode == 'I') ? pax->fiatoshis : pax->komodoshis;
|
||||||
@@ -340,7 +336,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
|||||||
{
|
{
|
||||||
if ( komodo_paxfind(&space,txid,vout) == 0 )
|
if ( komodo_paxfind(&space,txid,vout) == 0 )
|
||||||
{
|
{
|
||||||
komodo_gateway_deposit(coinaddr,value,shortflag,base,fiatoshis,rmd160,txid,vout,kmdheight,height);
|
komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height);
|
||||||
} else printf("duplicate deposit\n");
|
} else printf("duplicate deposit\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -359,7 +355,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
|||||||
// printf("%02x",((uint8_t *)&txids[i])[j]);
|
// printf("%02x",((uint8_t *)&txids[i])[j]);
|
||||||
if ( komodo_paxmark(height,&space,txids[i],vouts[i],height) == 0 )
|
if ( komodo_paxmark(height,&space,txids[i],vouts[i],height) == 0 )
|
||||||
{
|
{
|
||||||
komodo_gateway_deposit(0,0,0,0,0,0,txids[i],vouts[i],height,0);
|
komodo_gateway_deposit(0,0,0,0,0,txids[i],vouts[i],height,0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -368,9 +364,23 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( tokomodo != 0 && opretbuf[0] == 'X' )
|
else if ( tokomodo != 0 && opretbuf[0] == 'W' )
|
||||||
{
|
{
|
||||||
// verify and update limits
|
// verify and update limits
|
||||||
|
for (i=0; i<n; i++)
|
||||||
|
{
|
||||||
|
for (j=0; j<32; j++)
|
||||||
|
printf("%02x",((uint8_t *)&txids[i])[j]);
|
||||||
|
printf(" withdraw\n");
|
||||||
|
if ( komodo_paxmark(height,&space,txids[i],vouts[i],height) == 0 )
|
||||||
|
{
|
||||||
|
komodo_gateway_deposit(0,0,0,0,0,txids[i],vouts[i],height,0);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//printf(" duplicate issuedtxid v%d i.%d of n.%d opretlen.%d\n",vouts[i],i,n,opretlen);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return(typestr);
|
return(typestr);
|
||||||
|
|||||||
@@ -99,7 +99,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams,
|
|||||||
}
|
}
|
||||||
|
|
||||||
#define ASSETCHAINS_MINHEIGHT 100
|
#define ASSETCHAINS_MINHEIGHT 100
|
||||||
#define ROUNDROBIN_DELAY 45
|
#define ROUNDROBIN_DELAY 60
|
||||||
extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE;
|
extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE;
|
||||||
extern char ASSETCHAINS_SYMBOL[16];
|
extern char ASSETCHAINS_SYMBOL[16];
|
||||||
extern std::string NOTARY_PUBKEY;
|
extern std::string NOTARY_PUBKEY;
|
||||||
@@ -604,7 +604,7 @@ void static BitcoinMiner(CWallet *pwallet)
|
|||||||
} else Mining_start = 0;
|
} else Mining_start = 0;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
|
||||||
fprintf(stderr,"%s start mining loop\n",ASSETCHAINS_SYMBOL);
|
fprintf(stderr,"%s start mining loop\n",ASSETCHAINS_SYMBOL);
|
||||||
// Hash state
|
// Hash state
|
||||||
KOMODO_CHOSEN_ONE = 0;
|
KOMODO_CHOSEN_ONE = 0;
|
||||||
@@ -632,13 +632,13 @@ void static BitcoinMiner(CWallet *pwallet)
|
|||||||
solutionTargetChecks.increment();
|
solutionTargetChecks.increment();
|
||||||
if ( UintToArith256(pblock->GetHash()) > hashTarget )
|
if ( UintToArith256(pblock->GetHash()) > hashTarget )
|
||||||
{
|
{
|
||||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
|
||||||
printf("missed target\n");
|
fprintf(stderr,"missed target\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && Mining_start != 0 && time(NULL) < Mining_start+ROUNDROBIN_DELAY )
|
if ( ASSETCHAINS_SYMBOL[0] == 0 && Mining_start != 0 && time(NULL) < Mining_start+ROUNDROBIN_DELAY )
|
||||||
{
|
{
|
||||||
printf("Round robin diff sleep %d\n",(int32_t)(Mining_start+ROUNDROBIN_DELAY-time(NULL)));
|
//printf("Round robin diff sleep %d\n",(int32_t)(Mining_start+ROUNDROBIN_DELAY-time(NULL)));
|
||||||
sleep(Mining_start+ROUNDROBIN_DELAY-time(NULL));
|
sleep(Mining_start+ROUNDROBIN_DELAY-time(NULL));
|
||||||
KOMODO_CHOSEN_ONE = 1;
|
KOMODO_CHOSEN_ONE = 1;
|
||||||
}
|
}
|
||||||
@@ -725,25 +725,25 @@ void static BitcoinMiner(CWallet *pwallet)
|
|||||||
{
|
{
|
||||||
if ( ASSETCHAINS_SYMBOL[0] == 0 || Mining_height >= 100 )
|
if ( ASSETCHAINS_SYMBOL[0] == 0 || Mining_height >= 100 )
|
||||||
{
|
{
|
||||||
fprintf(stderr,"no nodes, break\n");
|
//fprintf(stderr,"no nodes, break\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((UintToArith256(pblock->nNonce) & 0xffff) == 0xffff)
|
if ((UintToArith256(pblock->nNonce) & 0xffff) == 0xffff)
|
||||||
{
|
{
|
||||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
|
||||||
fprintf(stderr,"0xffff, break\n");
|
fprintf(stderr,"0xffff, break\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 60)
|
if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLast && GetTime() - nStart > 60)
|
||||||
{
|
{
|
||||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
|
||||||
fprintf(stderr,"timeout, break\n");
|
fprintf(stderr,"timeout, break\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if ( pindexPrev != chainActive.Tip() )
|
if ( pindexPrev != chainActive.Tip() )
|
||||||
{
|
{
|
||||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
|
||||||
fprintf(stderr,"Tip advanced, break\n");
|
fprintf(stderr,"Tip advanced, break\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user