Browse Source

Our intrepid warrior gazed at his Dragon and both knew what was needed

pull/305/head
Duke Leto 4 years ago
parent
commit
7524c64024
  1. 4
      src/cc/CCinclude.h
  2. 44
      src/cc/crypto777/OS_portable.h
  3. 4
      src/cc/includes/curve25519.h
  4. 14
      src/cc/oracles.cpp
  5. 26
      src/komodo.h
  6. 16
      src/komodo_ccdata.h
  7. 4
      src/komodo_defs.h
  8. 12
      src/komodo_gateway.h
  9. 8
      src/komodo_kv.h
  10. 160
      src/komodo_nSPV.h
  11. 54
      src/komodo_nSPV_fullnode.h
  12. 50
      src/komodo_nSPV_superlite.h
  13. 18
      src/komodo_pax.h
  14. 14
      src/komodo_port.c
  15. 60
      src/komodo_utils.h
  16. 4
      src/notaries_staked.h
  17. 10
      src/rpc/misc.cpp
  18. 2
      src/rpc/server.cpp
  19. 2
      src/rpc/server.h
  20. 16
      src/wallet/rpcwallet.cpp

4
src/cc/CCinclude.h

@ -309,8 +309,8 @@ int32_t myGet_mempool_txs(std::vector<CTransaction> &txs,uint8_t evalcode,uint8_
/// \endcond
/// \cond INTERNAL
int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp);
int32_t iguana_rwbignum(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *endianedp);
int32_t dragon_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp);
int32_t dragon_rwbignum(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *endianedp);
/// \endcond
CScript GetScriptForMultisig(int nRequired, const std::vector<CPubKey>& keys);

44
src/cc/crypto777/OS_portable.h

@ -15,7 +15,7 @@
#ifndef OS_PORTABLEH
#define OS_PORTABLEH
// iguana_OS has functions that invoke system calls. Whenever possible stdio and similar functions are use and most functions are fully portable and in this file. For things that require OS specific, the call is routed to iguana_OS_portable_* Usually, all but one OS can be handled with the same code, so iguana_OS_portable.c has most of this shared logic and an #ifdef iguana_OS_nonportable.c
// dragon_OS has functions that invoke system calls. Whenever possible stdio and similar functions are use and most functions are fully portable and in this file. For things that require OS specific, the call is routed to dragon_OS_portable_* Usually, all but one OS can be handled with the same code, so dragon_OS_portable.c has most of this shared logic and an #ifdef dragon_OS_nonportable.c
#ifdef __APPLE__
//#define LIQUIDITY_PROVIDER 1
@ -279,19 +279,19 @@ void *queue_clone(queue_t *clone,queue_t *queue,int32_t size);
int32_t queue_size(queue_t *queue);
char *mbstr(char *str,double n);
void iguana_memreset(struct OS_memspace *mem);
void iguana_mempurge(struct OS_memspace *mem);
void *iguana_meminit(struct OS_memspace *mem,char *name,void *ptr,int64_t totalsize,int32_t threadsafe);
void *iguana_memalloc(struct OS_memspace *mem,long size,int32_t clearflag);
int64_t iguana_memfree(struct OS_memspace *mem,void *ptr,int32_t size);
void dragon_memreset(struct OS_memspace *mem);
void dragon_mempurge(struct OS_memspace *mem);
void *dragon_meminit(struct OS_memspace *mem,char *name,void *ptr,int64_t totalsize,int32_t threadsafe);
void *dragon_memalloc(struct OS_memspace *mem,long size,int32_t clearflag);
int64_t dragon_memfree(struct OS_memspace *mem,void *ptr,int32_t size);
// generic functions
bits256 iguana_merkle(char *symbol,bits256 *tree,int32_t txn_count);
bits256 dragon_merkle(char *symbol,bits256 *tree,int32_t txn_count);
bits256 bits256_calctxid(char *symbol,uint8_t *serialized,int32_t len);
int32_t unhex(char c);
void touppercase(char *str);
uint32_t is_ipaddr(char *str);
void iguana_bitmap(char *space,int32_t max,char *name);
void dragon_bitmap(char *space,int32_t max,char *name);
double _pairaved(double valA,double valB);
int32_t unstringbits(char *buf,uint64_t bits);
uint64_t stringbits(char *str);
@ -383,26 +383,26 @@ void expand_ipbits(char *ipaddr,uint64_t ipbits);
void escape_code(char *escaped,char *str);
void SaM_PrepareIndices(void);
// iguana_serdes.c
// dragon_serdes.c
#ifndef IGUANA_LOG2PACKETSIZE
#define IGUANA_LOG2PACKETSIZE 22
#endif
#ifndef IGUANA_MAXPACKETSIZE
#define IGUANA_MAXPACKETSIZE (1 << IGUANA_LOG2PACKETSIZE)
#endif
struct iguana_msghdr { uint8_t netmagic[4]; char command[12]; uint8_t serdatalen[4],hash[4]; } PACKED;
int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp);
int32_t iguana_validatehdr(char *symbol,struct iguana_msghdr *H);
int32_t iguana_rwbignum(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *endianedp);
int32_t iguana_sethdr(struct iguana_msghdr *H,const uint8_t netmagic[4],char *command,uint8_t *data,int32_t datalen);
uint8_t *iguana_varint16(int32_t rwflag,uint8_t *serialized,uint16_t *varint16p);
uint8_t *iguana_varint32(int32_t rwflag,uint8_t *serialized,uint16_t *varint16p);
uint8_t *iguana_varint64(int32_t rwflag,uint8_t *serialized,uint32_t *varint32p);
int32_t iguana_rwvarint(int32_t rwflag,uint8_t *serialized,uint64_t *varint64p);
int32_t iguana_rwvarint32(int32_t rwflag,uint8_t *serialized,uint32_t *int32p);
int32_t iguana_rwvarstr(int32_t rwflag,uint8_t *serialized,int32_t maxlen,char *endianedp);
int32_t iguana_rwmem(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp);
struct dragon_msghdr { uint8_t netmagic[4]; char command[12]; uint8_t serdatalen[4],hash[4]; } PACKED;
int32_t dragon_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp);
int32_t dragon_validatehdr(char *symbol,struct dragon_msghdr *H);
int32_t dragon_rwbignum(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *endianedp);
int32_t dragon_sethdr(struct dragon_msghdr *H,const uint8_t netmagic[4],char *command,uint8_t *data,int32_t datalen);
uint8_t *dragon_varint16(int32_t rwflag,uint8_t *serialized,uint16_t *varint16p);
uint8_t *dragon_varint32(int32_t rwflag,uint8_t *serialized,uint16_t *varint16p);
uint8_t *dragon_varint64(int32_t rwflag,uint8_t *serialized,uint32_t *varint32p);
int32_t dragon_rwvarint(int32_t rwflag,uint8_t *serialized,uint64_t *varint64p);
int32_t dragon_rwvarint32(int32_t rwflag,uint8_t *serialized,uint32_t *int32p);
int32_t dragon_rwvarstr(int32_t rwflag,uint8_t *serialized,int32_t maxlen,char *endianedp);
int32_t dragon_rwmem(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp);
#define bits256_nonz(a) (((a).ulongs[0] | (a).ulongs[1] | (a).ulongs[2] | (a).ulongs[3]) != 0)
bits256 bits256_ave(bits256 a,bits256 b);

4
src/cc/includes/curve25519.h

@ -55,8 +55,8 @@ void vcalc_sha256(char hashstr[(256 >> 3) * 2 + 1],uint8_t hash[256 >> 3],uint8_
void vcalc_sha256cat(uint8_t hash[256 >> 3],uint8_t *src,int32_t len,uint8_t *src2,int32_t len2);
void vupdate_sha256(uint8_t hash[256 >> 3],struct sha256_vstate *state,uint8_t *src,int32_t len);
bits256 curve25519_shared(bits256 privkey,bits256 otherpub);
int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp);
int32_t iguana_rwbignum(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *endianedp);
int32_t dragon_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp);
int32_t dragon_rwbignum(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *endianedp);
uint32_t calc_crc32(uint32_t crc,const void *buf,size_t size);
uint64_t conv_NXTpassword(unsigned char *mysecret,unsigned char *mypublic,uint8_t *pass,int32_t passlen);

14
src/cc/oracles.cpp

@ -384,7 +384,7 @@ int32_t oracle_format(uint256 *hashp,int64_t *valp,char *str,uint8_t fmt,uint8_t
{
if ( len == 32 )
{
iguana_rwbignum(0,&data[offset],len,(uint8_t *)hashp);
dragon_rwbignum(0,&data[offset],len,(uint8_t *)hashp);
if ( str != 0 )
sprintf(str,"%s",uint256_str(_str,*hashp));
}
@ -395,9 +395,9 @@ int32_t oracle_format(uint256 *hashp,int64_t *valp,char *str,uint8_t fmt,uint8_t
switch ( len )
{
case 1: val = (int8_t)data[offset]; break;
case 2: iguana_rwnum(0,&data[offset],len,(void *)&val16); val = val16; break;
case 4: iguana_rwnum(0,&data[offset],len,(void *)&val32); val = val32; break;
case 8: iguana_rwnum(0,&data[offset],len,(void *)&val); break;
case 2: dragon_rwnum(0,&data[offset],len,(void *)&val16); val = val16; break;
case 4: dragon_rwnum(0,&data[offset],len,(void *)&val32); val = val32; break;
case 8: dragon_rwnum(0,&data[offset],len,(void *)&val); break;
}
if ( str != 0 )
sprintf(str,"%lld",(long long)val);
@ -408,9 +408,9 @@ int32_t oracle_format(uint256 *hashp,int64_t *valp,char *str,uint8_t fmt,uint8_t
switch ( len )
{
case 1: uval = data[offset]; break;
case 2: iguana_rwnum(0,&data[offset],len,(void *)&uval16); uval = uval16; break;
case 4: iguana_rwnum(0,&data[offset],len,(void *)&uval32); uval = uval32; break;
case 8: iguana_rwnum(0,&data[offset],len,(void *)&uval); break;
case 2: dragon_rwnum(0,&data[offset],len,(void *)&uval16); uval = uval16; break;
case 4: dragon_rwnum(0,&data[offset],len,(void *)&uval32); uval = uval32; break;
case 8: dragon_rwnum(0,&data[offset],len,(void *)&uval); break;
}
if ( str != 0 )
sprintf(str,"%llu",(long long)uval);

26
src/komodo.h

@ -631,10 +631,10 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar
notarized = 1;
if ( 0 && opretlen != 149 )
printf("[%s].%d (%s) matched.%d i.%d j.%d notarized.%d %llx opretlen.%d len.%d offset.%d opoffset.%d\n",ASSETCHAINS_SYMBOL,height,ccdata.symbol,matched,i,j,notarized,(long long)signedmask,opretlen,len,offset,opoffset);
len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&srchash);
len += iguana_rwnum(0,&scriptbuf[len],sizeof(*notarizedheightp),(uint8_t *)notarizedheightp);
len += dragon_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&srchash);
len += dragon_rwnum(0,&scriptbuf[len],sizeof(*notarizedheightp),(uint8_t *)notarizedheightp);
if ( matched != 0 )
len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&desttxid);
len += dragon_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&desttxid);
if ( matched != 0 )
validated = komodo_validate_chain(srchash,*notarizedheightp);
else validated = 1;
@ -655,13 +655,13 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar
//printf("nameoffset.%d len.%d + 36 %d opoffset.%d vs opretlen.%d\n",nameoffset,len,len+36,opoffset,opretlen);
if ( len+36-opoffset <= opretlen )
{
len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&MoM);
len += iguana_rwnum(0,&scriptbuf[len],sizeof(MoMdepth),(uint8_t *)&MoMdepth);
len += dragon_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&MoM);
len += dragon_rwnum(0,&scriptbuf[len],sizeof(MoMdepth),(uint8_t *)&MoMdepth);
ccdata.MoMdata.MoM = MoM;
ccdata.MoMdata.MoMdepth = MoMdepth & 0xffff;
if ( len+sizeof(ccdata.CCid)-opoffset <= opretlen )
{
len += iguana_rwnum(0,&scriptbuf[len],sizeof(ccdata.CCid),(uint8_t *)&ccdata.CCid);
len += dragon_rwnum(0,&scriptbuf[len],sizeof(ccdata.CCid),(uint8_t *)&ccdata.CCid);
//if ( ((MoMdepth>>16) & 0xffff) != (ccdata.CCid & 0xffff) )
// fprintf(stderr,"%s CCid mismatch %u != %u\n",ASSETCHAINS_SYMBOL,((MoMdepth>>16) & 0xffff),(ccdata.CCid & 0xffff));
ccdata.len = sizeof(ccdata.CCid);
@ -670,19 +670,19 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar
// MoMoM, depth, numpairs, (notarization ht, MoMoM offset)
if ( len+48-opoffset <= opretlen && strcmp(ccdata.symbol,ASSETCHAINS_SYMBOL) == 0 )
{
len += iguana_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.kmdstarti);
len += iguana_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.kmdendi);
len += iguana_rwbignum(0,&scriptbuf[len],sizeof(MoMoMdata.MoMoM),(uint8_t *)&MoMoMdata.MoMoM);
len += iguana_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.MoMoMdepth);
len += iguana_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.numpairs);
len += dragon_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.kmdstarti);
len += dragon_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.kmdendi);
len += dragon_rwbignum(0,&scriptbuf[len],sizeof(MoMoMdata.MoMoM),(uint8_t *)&MoMoMdata.MoMoM);
len += dragon_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.MoMoMdepth);
len += dragon_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.numpairs);
MoMoMdata.len += sizeof(MoMoMdata.MoMoM) + sizeof(uint32_t)*4;
if ( len+MoMoMdata.numpairs*8-opoffset == opretlen )
{
MoMoMdata.pairs = (struct komodo_ccdatapair *)calloc(MoMoMdata.numpairs,sizeof(*MoMoMdata.pairs));
for (k=0; k<MoMoMdata.numpairs; k++)
{
len += iguana_rwnum(0,&scriptbuf[len],sizeof(int32_t),(uint8_t *)&MoMoMdata.pairs[k].notarized_height);
len += iguana_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.pairs[k].MoMoMoffset);
len += dragon_rwnum(0,&scriptbuf[len],sizeof(int32_t),(uint8_t *)&MoMoMdata.pairs[k].notarized_height);
len += dragon_rwnum(0,&scriptbuf[len],sizeof(uint32_t),(uint8_t *)&MoMoMdata.pairs[k].MoMoMoffset);
MoMoMdata.len += sizeof(uint32_t) * 2;
}
} else ccdata.len = MoMoMdata.len = 0;

16
src/komodo_ccdata.h

@ -147,12 +147,12 @@ int32_t komodo_MoMoMdata(char *hexstr,int32_t hexsize,struct komodo_ccdataMoMoM
}
if ( mdata->numpairs > 0 )
{
len += iguana_rwnum(1,&hexdata[len],sizeof(CCid),(uint8_t *)&CCid);
len += iguana_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->kmdstarti);
len += iguana_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->kmdendi);
len += iguana_rwbignum(1,&hexdata[len],sizeof(mdata->MoMoM),(uint8_t *)&mdata->MoMoM);
len += iguana_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->MoMoMdepth);
len += iguana_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->numpairs);
len += dragon_rwnum(1,&hexdata[len],sizeof(CCid),(uint8_t *)&CCid);
len += dragon_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->kmdstarti);
len += dragon_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->kmdendi);
len += dragon_rwbignum(1,&hexdata[len],sizeof(mdata->MoMoM),(uint8_t *)&mdata->MoMoM);
len += dragon_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->MoMoMdepth);
len += dragon_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->numpairs);
for (i=0; i<mdata->numpairs; i++)
{
if ( len + sizeof(uint32_t)*2 > sizeof(hexdata) )
@ -160,8 +160,8 @@ int32_t komodo_MoMoMdata(char *hexstr,int32_t hexsize,struct komodo_ccdataMoMoM
fprintf(stderr,"%s %d %d i.%d of %d exceeds hexdata.%d\n",symbol,kmdheight,notarized_height,i,mdata->numpairs,(int32_t)sizeof(hexdata));
break;
}
len += iguana_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->pairs[i].notarized_height);
len += iguana_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->pairs[i].MoMoMoffset);
len += dragon_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->pairs[i].notarized_height);
len += dragon_rwnum(1,&hexdata[len],sizeof(uint32_t),(uint8_t *)&mdata->pairs[i].MoMoMoffset);
}
if ( i == mdata->numpairs && len*2+1 < hexsize )
{

4
src/komodo_defs.h

@ -265,7 +265,7 @@ static const char *notaries_elected[NUM_KMD_SEASONS][NUM_KMD_NOTARIES][2] =
{"decker_AR", "03ffdf1a116300a78729608d9930742cd349f11a9d64fcc336b8f18592dd9c91bc" }, // 63
},
{
// Season 3.5 third party NN pubkeys from https://github.com/KomodoPlatform/dPoW/blob/master/iguana/3rd_party
// Season 3.5 third party NN pubkeys from https://github.com/KomodoPlatform/dPoW/blob/master/dragon/3rd_party
{"madmax_NA", "02ef81a360411adf71184ff04d0c5793fc41fd1d7155a28dd909f21f35f4883ac1" },
{"alright_AR", "036a6bca1c2a8166f79fa8a979662892742346cc972b432f8e61950a358d705517" },
{"strob_NA", "02049202f3872877e81035549f6f3a0f868d0ad1c9b0e0d2b48b1f30324255d26d" },
@ -332,7 +332,7 @@ static const char *notaries_elected[NUM_KMD_SEASONS][NUM_KMD_NOTARIES][2] =
{"decker_AR", "02a85540db8d41c7e60bf0d33d1364b4151cad883dd032878ea4c037f67b769635" }
},
{
// Season 4 https://github.com/KomodoPlatform/dPoW/blob/s4/iguana/3rd_party
// Season 4 https://github.com/KomodoPlatform/dPoW/blob/s4/dragon/3rd_party
{"alien_AR", "024f20c096b085308e21893383f44b4faf1cdedea9ad53cc7d7e7fbfa0c30c1e71" },
{"alien_EU", "022b85908191788f409506ebcf96a892f3274f352864c3ed566c5a16de63953236" },
{"alien_NA", "022f62b56ddfd07c9860921c701285ac39bb3ac8f6f083d1b59c8f4943be3de162" },

12
src/komodo_gateway.h

@ -188,10 +188,10 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio
pax->vout += ((uint32_t)opretbuf[len++] << 8);
//printf(" txid v.%d\n",pax->vout);
}
len += iguana_rwnum(rwflag,&opretbuf[len],sizeof(pax->komodoshis),&pax->komodoshis);
len += iguana_rwnum(rwflag,&opretbuf[len],sizeof(pax->fiatoshis),&pax->fiatoshis);
len += iguana_rwnum(rwflag,&opretbuf[len],sizeof(pax->height),&pax->height);
len += iguana_rwnum(rwflag,&opretbuf[len],sizeof(pax->otherheight),&pax->otherheight);
len += dragon_rwnum(rwflag,&opretbuf[len],sizeof(pax->komodoshis),&pax->komodoshis);
len += dragon_rwnum(rwflag,&opretbuf[len],sizeof(pax->fiatoshis),&pax->fiatoshis);
len += dragon_rwnum(rwflag,&opretbuf[len],sizeof(pax->height),&pax->height);
len += dragon_rwnum(rwflag,&opretbuf[len],sizeof(pax->otherheight),&pax->otherheight);
if ( rwflag != 0 )
{
memcpy(&opretbuf[len],pax->rmd160,20), len += 20;
@ -855,7 +855,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
tokomodo = 0;
if ( opretlen == 38 ) // any KMD tx
{
iguana_rwnum(0,&opretbuf[34],sizeof(kmdheight),&kmdheight);
dragon_rwnum(0,&opretbuf[34],sizeof(kmdheight),&kmdheight);
memset(base,0,sizeof(base));
PAX_pubkey(0,&opretbuf[1],&addrtype,rmd160,base,&shortflag,&fiatoshis);
bitcoin_address(coinaddr,addrtype,rmd160,20);
@ -998,7 +998,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
return(typestr);
}
tokomodo = 1;
iguana_rwnum(0,&opretbuf[34],sizeof(kmdheight),&kmdheight);
dragon_rwnum(0,&opretbuf[34],sizeof(kmdheight),&kmdheight);
memset(base,0,sizeof(base));
PAX_pubkey(0,&opretbuf[1],&addrtype,rmd160,base,&shortflag,&komodoshis);
bitcoin_address(coinaddr,addrtype,rmd160,20);

8
src/komodo_kv.h

@ -103,10 +103,10 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value)
uint32_t flags; uint256 pubkey,refpubkey,sig; int32_t i,refvaluesize,hassig,coresize,haspubkey,height,kvheight; uint16_t keylen,valuesize,newflag = 0; uint8_t *key,*valueptr,keyvalue[IGUANA_MAXSCRIPTSIZE*8]; struct komodo_kv *ptr; char *transferpubstr,*tstr; uint64_t fee;
if ( ASSETCHAINS_SYMBOL[0] == 0 ) // disable KV for KMD
return;
iguana_rwnum(0,&opretbuf[1],sizeof(keylen),&keylen);
iguana_rwnum(0,&opretbuf[3],sizeof(valuesize),&valuesize);
iguana_rwnum(0,&opretbuf[5],sizeof(height),&height);
iguana_rwnum(0,&opretbuf[9],sizeof(flags),&flags);
dragon_rwnum(0,&opretbuf[1],sizeof(keylen),&keylen);
dragon_rwnum(0,&opretbuf[3],sizeof(valuesize),&valuesize);
dragon_rwnum(0,&opretbuf[5],sizeof(height),&height);
dragon_rwnum(0,&opretbuf[9],sizeof(flags),&flags);
key = &opretbuf[13];
if ( keylen+13 > opretlen )
{

160
src/komodo_nSPV.h

@ -26,7 +26,7 @@
#ifndef KOMODO_NSPV_H
#define KOMODO_NSPV_H
int32_t iguana_rwbuf(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *buf)
int32_t dragon_rwbuf(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *buf)
{
if ( rwflag != 0 )
memcpy(serialized,buf,len);
@ -37,21 +37,21 @@ int32_t iguana_rwbuf(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *buf
int32_t NSPV_rwequihdr(int32_t rwflag,uint8_t *serialized,struct NSPV_equihdr *ptr)
{
int32_t len = 0;
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nVersion),&ptr->nVersion);
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->hashPrevBlock),(uint8_t *)&ptr->hashPrevBlock);
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->hashMerkleRoot),(uint8_t *)&ptr->hashMerkleRoot);
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->hashFinalSaplingRoot),(uint8_t *)&ptr->hashFinalSaplingRoot);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nTime),&ptr->nTime);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nBits),&ptr->nBits);
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->nNonce),(uint8_t *)&ptr->nNonce);
len += iguana_rwbuf(rwflag,&serialized[len],sizeof(ptr->nSolution),ptr->nSolution);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->nVersion),&ptr->nVersion);
len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->hashPrevBlock),(uint8_t *)&ptr->hashPrevBlock);
len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->hashMerkleRoot),(uint8_t *)&ptr->hashMerkleRoot);
len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->hashFinalSaplingRoot),(uint8_t *)&ptr->hashFinalSaplingRoot);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->nTime),&ptr->nTime);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->nBits),&ptr->nBits);
len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->nNonce),(uint8_t *)&ptr->nNonce);
len += dragon_rwbuf(rwflag,&serialized[len],sizeof(ptr->nSolution),ptr->nSolution);
return(len);
}
int32_t iguana_rwequihdrvec(int32_t rwflag,uint8_t *serialized,uint16_t *vecsizep,struct NSPV_equihdr **ptrp)
int32_t dragon_rwequihdrvec(int32_t rwflag,uint8_t *serialized,uint16_t *vecsizep,struct NSPV_equihdr **ptrp)
{
int32_t i,vsize,len = 0;
len += iguana_rwnum(rwflag,&serialized[len],sizeof(*vecsizep),vecsizep);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(*vecsizep),vecsizep);
if ( (vsize= *vecsizep) != 0 )
{
//fprintf(stderr,"vsize.%d ptrp.%p alloc %ld\n",vsize,*ptrp,sizeof(struct NSPV_equihdr)*vsize);
@ -63,15 +63,15 @@ int32_t iguana_rwequihdrvec(int32_t rwflag,uint8_t *serialized,uint16_t *vecsize
return(len);
}
int32_t iguana_rwuint8vec(int32_t rwflag,uint8_t *serialized,int32_t *biglenp,uint8_t **ptrp)
int32_t dragon_rwuint8vec(int32_t rwflag,uint8_t *serialized,int32_t *biglenp,uint8_t **ptrp)
{
int32_t vsize,len = 0;
len += iguana_rwnum(rwflag,&serialized[len],sizeof(*biglenp),biglenp);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(*biglenp),biglenp);
if ( (vsize= *biglenp) > 0 && vsize < MAX_TX_SIZE_AFTER_SAPLING )
{
if ( *ptrp == 0 )
*ptrp = (uint8_t *)calloc(1,vsize);
len += iguana_rwbuf(rwflag,&serialized[len],vsize,*ptrp);
len += dragon_rwbuf(rwflag,&serialized[len],vsize,*ptrp);
}
return(len);
}
@ -79,18 +79,18 @@ int32_t iguana_rwuint8vec(int32_t rwflag,uint8_t *serialized,int32_t *biglenp,ui
int32_t NSPV_rwutxoresp(int32_t rwflag,uint8_t *serialized,struct NSPV_utxoresp *ptr)
{
int32_t len = 0;
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->satoshis),&ptr->satoshis);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->extradata),&ptr->extradata);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->height),&ptr->height);
len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->satoshis),&ptr->satoshis);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->extradata),&ptr->extradata);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->height),&ptr->height);
return(len);
}
int32_t NSPV_rwutxosresp(int32_t rwflag,uint8_t *serialized,struct NSPV_utxosresp *ptr) // check mempool
{
int32_t i,len = 0;
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->numutxos),&ptr->numutxos);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->numutxos),&ptr->numutxos);
if ( ptr->numutxos != 0 )
{
if ( ptr->utxos == 0 )
@ -98,12 +98,12 @@ int32_t NSPV_rwutxosresp(int32_t rwflag,uint8_t *serialized,struct NSPV_utxosres
for (i=0; i<ptr->numutxos; i++)
len += NSPV_rwutxoresp(rwflag,&serialized[len],&ptr->utxos[i]);
}
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->total),&ptr->total);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->interest),&ptr->interest);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nodeheight),&ptr->nodeheight);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->filter),&ptr->filter);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->CCflag),&ptr->CCflag);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->skipcount),&ptr->skipcount);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->total),&ptr->total);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->interest),&ptr->interest);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->nodeheight),&ptr->nodeheight);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->filter),&ptr->filter);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->CCflag),&ptr->CCflag);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->skipcount),&ptr->skipcount);
if ( rwflag != 0 )
{
memcpy(&serialized[len],ptr->coinaddr,sizeof(ptr->coinaddr));
@ -140,17 +140,17 @@ void NSPV_utxosresp_copy(struct NSPV_utxosresp *dest,struct NSPV_utxosresp *ptr)
int32_t NSPV_rwtxidresp(int32_t rwflag,uint8_t *serialized,struct NSPV_txidresp *ptr)
{
int32_t len = 0;
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->satoshis),&ptr->satoshis);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->height),&ptr->height);
len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->satoshis),&ptr->satoshis);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->height),&ptr->height);
return(len);
}
int32_t NSPV_rwtxidsresp(int32_t rwflag,uint8_t *serialized,struct NSPV_txidsresp *ptr)
{
int32_t i,len = 0;
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->numtxids),&ptr->numtxids);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->numtxids),&ptr->numtxids);
if ( ptr->numtxids != 0 )
{
if ( ptr->txids == 0 )
@ -158,10 +158,10 @@ int32_t NSPV_rwtxidsresp(int32_t rwflag,uint8_t *serialized,struct NSPV_txidsres
for (i=0; i<ptr->numtxids; i++)
len += NSPV_rwtxidresp(rwflag,&serialized[len],&ptr->txids[i]);
}
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nodeheight),&ptr->nodeheight);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->filter),&ptr->filter);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->CCflag),&ptr->CCflag);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->skipcount),&ptr->skipcount);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->nodeheight),&ptr->nodeheight);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->filter),&ptr->filter);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->CCflag),&ptr->CCflag);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->skipcount),&ptr->skipcount);
if ( rwflag != 0 )
{
memcpy(&serialized[len],ptr->coinaddr,sizeof(ptr->coinaddr));
@ -199,20 +199,20 @@ void NSPV_txidsresp_copy(struct NSPV_txidsresp *dest,struct NSPV_txidsresp *ptr)
int32_t NSPV_rwmempoolresp(int32_t rwflag,uint8_t *serialized,struct NSPV_mempoolresp *ptr)
{
int32_t i,len = 0;
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->numtxids),&ptr->numtxids);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->numtxids),&ptr->numtxids);
if ( ptr->numtxids != 0 )
{
if ( ptr->txids == 0 )
ptr->txids = (uint256 *)calloc(sizeof(*ptr->txids),ptr->numtxids);
for (i=0; i<ptr->numtxids; i++)
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->txids[i]),(uint8_t *)&ptr->txids[i]);
len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->txids[i]),(uint8_t *)&ptr->txids[i]);
}
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nodeheight),&ptr->nodeheight);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->vindex),&ptr->vindex);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->CCflag),&ptr->CCflag);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->funcid),&ptr->funcid);
len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->nodeheight),&ptr->nodeheight);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->vindex),&ptr->vindex);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->CCflag),&ptr->CCflag);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->funcid),&ptr->funcid);
if ( rwflag != 0 )
{
memcpy(&serialized[len],ptr->coinaddr,sizeof(ptr->coinaddr));
@ -250,12 +250,12 @@ void NSPV_mempoolresp_copy(struct NSPV_mempoolresp *dest,struct NSPV_mempoolresp
int32_t NSPV_rwntz(int32_t rwflag,uint8_t *serialized,struct NSPV_ntz *ptr)
{
int32_t len = 0;
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->blockhash),(uint8_t *)&ptr->blockhash);
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid);
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->othertxid),(uint8_t *)&ptr->othertxid);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->height),&ptr->height);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->txidheight),&ptr->txidheight);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->timestamp),&ptr->timestamp);
len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->blockhash),(uint8_t *)&ptr->blockhash);
len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid);
len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->othertxid),(uint8_t *)&ptr->othertxid);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->height),&ptr->height);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->txidheight),&ptr->txidheight);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->timestamp),&ptr->timestamp);
return(len);
}
@ -264,7 +264,7 @@ int32_t NSPV_rwntzsresp(int32_t rwflag,uint8_t *serialized,struct NSPV_ntzsresp
int32_t len = 0;
len += NSPV_rwntz(rwflag,&serialized[len],&ptr->prevntz);
len += NSPV_rwntz(rwflag,&serialized[len],&ptr->nextntz);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->reqheight),&ptr->reqheight);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->reqheight),&ptr->reqheight);
return(len);
}
@ -283,11 +283,11 @@ int32_t NSPV_rwinforesp(int32_t rwflag,uint8_t *serialized,struct NSPV_inforesp
{
int32_t len = 0;
len += NSPV_rwntz(rwflag,&serialized[len],&ptr->notarization);
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->blockhash),(uint8_t *)&ptr->blockhash);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->height),&ptr->height);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->hdrheight),&ptr->hdrheight);
len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->blockhash),(uint8_t *)&ptr->blockhash);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->height),&ptr->height);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->hdrheight),&ptr->hdrheight);
len += NSPV_rwequihdr(rwflag,&serialized[len],&ptr->H);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->version),&ptr->version);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->version),&ptr->version);
//fprintf(stderr,"getinfo rwlen.%d\n",len);
return(len);
}
@ -301,13 +301,13 @@ void NSPV_inforesp_purge(struct NSPV_inforesp *ptr)
int32_t NSPV_rwtxproof(int32_t rwflag,uint8_t *serialized,struct NSPV_txproof *ptr)
{
int32_t len = 0;
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->unspentvalue),&ptr->unspentvalue);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->height),&ptr->height);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout);
len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->txlen,&ptr->tx);
len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->txprooflen,&ptr->txproof);
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->hashblock),(uint8_t *)&ptr->hashblock);
len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->unspentvalue),&ptr->unspentvalue);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->height),&ptr->height);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout);
len += dragon_rwuint8vec(rwflag,&serialized[len],&ptr->txlen,&ptr->tx);
len += dragon_rwuint8vec(rwflag,&serialized[len],&ptr->txprooflen,&ptr->txproof);
len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->hashblock),(uint8_t *)&ptr->hashblock);
return(len);
}
@ -341,11 +341,11 @@ void NSPV_txproof_purge(struct NSPV_txproof *ptr)
int32_t NSPV_rwntzproofshared(int32_t rwflag,uint8_t *serialized,struct NSPV_ntzproofshared *ptr)
{
int32_t len = 0;
len += iguana_rwequihdrvec(rwflag,&serialized[len],&ptr->numhdrs,&ptr->hdrs);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->prevht),&ptr->prevht);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nextht),&ptr->nextht);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->pad32),&ptr->pad32);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->pad16),&ptr->pad16);
len += dragon_rwequihdrvec(rwflag,&serialized[len],&ptr->numhdrs,&ptr->hdrs);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->prevht),&ptr->prevht);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->nextht),&ptr->nextht);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->pad32),&ptr->pad32);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->pad16),&ptr->pad16);
//fprintf(stderr,"rwcommon prev.%d next.%d\n",ptr->prevht,ptr->nextht);
return(len);
}
@ -354,12 +354,12 @@ int32_t NSPV_rwntzsproofresp(int32_t rwflag,uint8_t *serialized,struct NSPV_ntzs
{
int32_t len = 0;
len += NSPV_rwntzproofshared(rwflag,&serialized[len],&ptr->common);
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->prevtxid),(uint8_t *)&ptr->prevtxid);
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->nexttxid),(uint8_t *)&ptr->nexttxid);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->prevtxidht),&ptr->prevtxidht);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->nexttxidht),&ptr->nexttxidht);
len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->prevtxlen,&ptr->prevntz);
len += iguana_rwuint8vec(rwflag,&serialized[len],&ptr->nexttxlen,&ptr->nextntz);
len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->prevtxid),(uint8_t *)&ptr->prevtxid);
len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->nexttxid),(uint8_t *)&ptr->nexttxid);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->prevtxidht),&ptr->prevtxidht);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->nexttxidht),&ptr->nexttxidht);
len += dragon_rwuint8vec(rwflag,&serialized[len],&ptr->prevtxlen,&ptr->prevntz);
len += dragon_rwuint8vec(rwflag,&serialized[len],&ptr->nexttxlen,&ptr->nextntz);
//fprintf(stderr,"retlen.%d\n",len);
return(len);
}
@ -402,9 +402,9 @@ int32_t NSPV_rwspentinfo(int32_t rwflag,uint8_t *serialized,struct NSPV_spentinf
{
int32_t len = 0;
len += NSPV_rwtxproof(rwflag,&serialized[len],&ptr->spent);
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->spentvini),&ptr->spentvini);
len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->vout),&ptr->vout);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->spentvini),&ptr->spentvini);
return(len);
}
@ -420,8 +420,8 @@ void NSPV_spentinfo_purge(struct NSPV_spentinfo *ptr)
int32_t NSPV_rwbroadcastresp(int32_t rwflag,uint8_t *serialized,struct NSPV_broadcastresp *ptr)
{
int32_t len = 0;
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(ptr->retcode),&ptr->retcode);
len += dragon_rwbignum(rwflag,&serialized[len],sizeof(ptr->txid),(uint8_t *)&ptr->txid);
len += dragon_rwnum(rwflag,&serialized[len],sizeof(ptr->retcode),&ptr->retcode);
return(len);
}
@ -434,8 +434,8 @@ void NSPV_broadcast_purge(struct NSPV_broadcastresp *ptr)
int32_t NSPV_rwremoterpcresp(int32_t rwflag,uint8_t *serialized,struct NSPV_remoterpcresp *ptr, int32_t slen)
{
int32_t len = 0;
len+=iguana_rwbuf(rwflag,&serialized[len],sizeof(ptr->method),(uint8_t*)ptr->method);
len+=iguana_rwbuf(rwflag,&serialized[len],slen-len,(uint8_t*)ptr->json);
len+=dragon_rwbuf(rwflag,&serialized[len],sizeof(ptr->method),(uint8_t*)ptr->method);
len+=dragon_rwbuf(rwflag,&serialized[len],slen-len,(uint8_t*)ptr->json);
return(len);
}
@ -562,7 +562,7 @@ int32_t NSPV_notariescount(CTransaction tx,uint8_t elected[64][33])
uint256 NSPV_opretextract(int32_t *heightp,uint256 *blockhashp,char *symbol,std::vector<uint8_t> opret,uint256 txid)
{
uint256 desttxid; int32_t i;
iguana_rwnum(0,&opret[32],sizeof(*heightp),heightp);
dragon_rwnum(0,&opret[32],sizeof(*heightp),heightp);
for (i=0; i<32; i++)
((uint8_t *)blockhashp)[i] = opret[i];
for (i=0; i<32; i++)

54
src/komodo_nSPV_fullnode.h

@ -637,13 +637,13 @@ int32_t NSPV_mempooltxids(struct NSPV_mempoolresp *ptr,char *coinaddr,uint8_t is
for (i=0; i<ptr->numtxids; i++)
{
tmp = txids[i];
iguana_rwbignum(0,(uint8_t *)&tmp,sizeof(*ptr->txids),(uint8_t *)&ptr->txids[i]);
dragon_rwbignum(0,(uint8_t *)&tmp,sizeof(*ptr->txids),(uint8_t *)&ptr->txids[i]);
}
}
if ( funcid == NSPV_MEMPOOL_ADDRESS )
{
memcpy(&tmp,&satoshis,sizeof(tmp));
iguana_rwbignum(0,(uint8_t *)&tmp,sizeof(ptr->txid),(uint8_t *)&ptr->txid);
dragon_rwbignum(0,(uint8_t *)&tmp,sizeof(ptr->txid),(uint8_t *)&ptr->txid);
}
len = (int32_t)(sizeof(*ptr) + sizeof(*ptr->txids)*ptr->numtxids - sizeof(ptr->txids));
return(len);
@ -883,7 +883,7 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
{
struct NSPV_inforesp I;
if ( len == 1+sizeof(reqheight) )
iguana_rwnum(0,&request[1],sizeof(reqheight),&reqheight);
dragon_rwnum(0,&request[1],sizeof(reqheight),&reqheight);
else reqheight = 0;
//fprintf(stderr,"request height.%d\n",reqheight);
memset(&I,0,sizeof(I));
@ -918,13 +918,13 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
else if ( request[1] == len-7 )
{
isCC = (request[len-5] != 0);
iguana_rwnum(0,&request[len-4],sizeof(skipcount),&skipcount);
dragon_rwnum(0,&request[len-4],sizeof(skipcount),&skipcount);
}
else
{
isCC = (request[len-9] != 0);
iguana_rwnum(0,&request[len-8],sizeof(skipcount),&skipcount);
iguana_rwnum(0,&request[len-4],sizeof(filter),&filter);
dragon_rwnum(0,&request[len-8],sizeof(skipcount),&skipcount);
dragon_rwnum(0,&request[len-4],sizeof(filter),&filter);
}
if ( 0 && isCC != 0 )
fprintf(stderr,"utxos %s isCC.%d skipcount.%d filter.%x\n",coinaddr,isCC,skipcount,filter);
@ -958,13 +958,13 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
else if ( request[1] == len-7 )
{
isCC = (request[len-5] != 0);
iguana_rwnum(0,&request[len-4],sizeof(skipcount),&skipcount);
dragon_rwnum(0,&request[len-4],sizeof(skipcount),&skipcount);
}
else
{
isCC = (request[len-9] != 0);
iguana_rwnum(0,&request[len-8],sizeof(skipcount),&skipcount);
iguana_rwnum(0,&request[len-4],sizeof(filter),&filter);
dragon_rwnum(0,&request[len-8],sizeof(skipcount),&skipcount);
dragon_rwnum(0,&request[len-4],sizeof(filter),&filter);
}
if ( 0 && isCC != 0 )
fprintf(stderr,"txids %s isCC.%d skipcount.%d filter.%d\n",coinaddr,isCC,skipcount,filter);
@ -993,10 +993,10 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
{
int32_t vout; uint256 txid; uint8_t funcid,isCC = 0;
n = 1;
n += iguana_rwnum(0,&request[n],sizeof(isCC),&isCC);
n += iguana_rwnum(0,&request[n],sizeof(funcid),&funcid);
n += iguana_rwnum(0,&request[n],sizeof(vout),&vout);
n += iguana_rwbignum(0,&request[n],sizeof(txid),(uint8_t *)&txid);
n += dragon_rwnum(0,&request[n],sizeof(isCC),&isCC);
n += dragon_rwnum(0,&request[n],sizeof(funcid),&funcid);
n += dragon_rwnum(0,&request[n],sizeof(vout),&vout);
n += dragon_rwbignum(0,&request[n],sizeof(txid),(uint8_t *)&txid);
slen = request[n++];
if ( slen < 63 )
{
@ -1028,7 +1028,7 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
struct NSPV_ntzsresp N; int32_t height;
if ( len == 1+sizeof(height) )
{
iguana_rwnum(0,&request[1],sizeof(height),&height);
dragon_rwnum(0,&request[1],sizeof(height),&height);
memset(&N,0,sizeof(N));
if ( (slen= NSPV_getntzsresp(&N,height)) > 0 )
{
@ -1051,8 +1051,8 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
struct NSPV_ntzsproofresp P; uint256 prevntz,nextntz;
if ( len == 1+sizeof(prevntz)+sizeof(nextntz) )
{
iguana_rwbignum(0,&request[1],sizeof(prevntz),(uint8_t *)&prevntz);
iguana_rwbignum(0,&request[1+sizeof(prevntz)],sizeof(nextntz),(uint8_t *)&nextntz);
dragon_rwbignum(0,&request[1],sizeof(prevntz),(uint8_t *)&prevntz);
dragon_rwbignum(0,&request[1+sizeof(prevntz)],sizeof(nextntz),(uint8_t *)&nextntz);
memset(&P,0,sizeof(P));
if ( (slen= NSPV_getntzsproofresp(&P,prevntz,nextntz)) > 0 )
{
@ -1076,9 +1076,9 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
struct NSPV_txproof P; uint256 txid; int32_t height,vout;
if ( len == 1+sizeof(txid)+sizeof(height)+sizeof(vout) )
{
iguana_rwnum(0,&request[1],sizeof(height),&height);
iguana_rwnum(0,&request[1+sizeof(height)],sizeof(vout),&vout);
iguana_rwbignum(0,&request[1+sizeof(height)+sizeof(vout)],sizeof(txid),(uint8_t *)&txid);
dragon_rwnum(0,&request[1],sizeof(height),&height);
dragon_rwnum(0,&request[1+sizeof(height)],sizeof(vout),&vout);
dragon_rwbignum(0,&request[1+sizeof(height)+sizeof(vout)],sizeof(txid),(uint8_t *)&txid);
//fprintf(stderr,"got txid %s/v%d ht.%d\n",txid.GetHex().c_str(),vout,height);
memset(&P,0,sizeof(P));
if ( (slen= NSPV_gettxproof(&P,vout,txid,height)) > 0 )
@ -1104,8 +1104,8 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
struct NSPV_spentinfo S; int32_t vout; uint256 txid;
if ( len == 1+sizeof(txid)+sizeof(vout) )
{
iguana_rwnum(0,&request[1],sizeof(vout),&vout);
iguana_rwbignum(0,&request[1+sizeof(vout)],sizeof(txid),(uint8_t *)&txid);
dragon_rwnum(0,&request[1],sizeof(vout),&vout);
dragon_rwbignum(0,&request[1+sizeof(vout)],sizeof(txid),(uint8_t *)&txid);
memset(&S,0,sizeof(S));
if ( (slen= NSPV_getspentinfo(&S,txid,vout)) > 0 )
{
@ -1128,8 +1128,8 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
struct NSPV_broadcastresp B; uint32_t n,offset; uint256 txid;
if ( len > 1+sizeof(txid)+sizeof(n) )
{
iguana_rwbignum(0,&request[1],sizeof(txid),(uint8_t *)&txid);
iguana_rwnum(0,&request[1+sizeof(txid)],sizeof(n),&n);
dragon_rwbignum(0,&request[1],sizeof(txid),(uint8_t *)&txid);
dragon_rwnum(0,&request[1+sizeof(txid)],sizeof(n),&n);
memset(&B,0,sizeof(B));
offset = 1 + sizeof(txid) + sizeof(n);
if ( n < MAX_TX_SIZE_AFTER_SAPLING && request.size() == offset+n && (slen= NSPV_sendrawtransaction(&B,&request[offset],n)) > 0 )
@ -1152,7 +1152,7 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
{
struct NSPV_remoterpcresp R; int32_t p;
p = 1;
p+=iguana_rwnum(0,&request[p],sizeof(slen),&slen);
p+=dragon_rwnum(0,&request[p],sizeof(slen),&slen);
memset(&R,0,sizeof(R));
if (request.size() == p+slen && (slen=NSPV_remoterpc(&R,(char *)&request[p],slen))>0 )
{
@ -1191,9 +1191,9 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
memcpy(coinaddr, &request[n], addrlen);
coinaddr[addrlen] = 0;
n += addrlen;
iguana_rwnum(0, &request[n], sizeof(amount), &amount);
dragon_rwnum(0, &request[n], sizeof(amount), &amount);
n += sizeof(amount);
iguana_rwnum(0, &request[n], sizeof(evalcode), &evalcode);
dragon_rwnum(0, &request[n], sizeof(evalcode), &evalcode);
n += sizeof(evalcode);
int32_t funcidslen = request[n++];
@ -1202,7 +1202,7 @@ void komodo_nSPVreq(CNode *pfrom,std::vector<uint8_t> request) // received a req
memcpy(funcids, &request[n], funcidslen);
funcids[funcidslen] = 0;
n += funcidslen;
iguana_rwbignum(0, &request[n], sizeof(filtertxid), (uint8_t *)&filtertxid);
dragon_rwbignum(0, &request[n], sizeof(filtertxid), (uint8_t *)&filtertxid);
std::cerr << __func__ << " " << "request addr=" << coinaddr << " amount=" << amount << " evalcode=" << (int)evalcode << " funcids=" << funcids << " filtertxid=" << filtertxid.GetHex() << std::endl;
memset(&U, 0, sizeof(U));

50
src/komodo_nSPV_superlite.h

@ -293,7 +293,7 @@ void komodo_nSPV(CNode *pto) // polling loop from SendMessages
reqht = 0;
len = 0;
msg[len++] = NSPV_INFO;
len += iguana_rwnum(1,&msg[len],sizeof(reqht),&reqht);
len += dragon_rwnum(1,&msg[len],sizeof(reqht),&reqht);
//fprintf(stderr,"issue getinfo\n");
NSPV_req(pto,msg,len,NODE_NSPV,NSPV_INFO>>1);
}
@ -556,7 +556,7 @@ UniValue NSPV_getinfo_req(int32_t reqht)
uint8_t msg[512]; int32_t i,iter,len = 0; struct NSPV_inforesp I;
NSPV_inforesp_purge(&NSPV_inforesult);
msg[len++] = NSPV_INFO;
len += iguana_rwnum(1,&msg[len],sizeof(reqht),&reqht);
len += dragon_rwnum(1,&msg[len],sizeof(reqht),&reqht);
for (iter=0; iter<3; iter++)
if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 )
{
@ -609,8 +609,8 @@ UniValue NSPV_addressutxos(char *coinaddr,int32_t CCflag,int32_t skipcount,int32
msg[len++] = slen;
memcpy(&msg[len],coinaddr,slen), len += slen;
msg[len++] = (CCflag != 0);
len += iguana_rwnum(1,&msg[len],sizeof(skipcount),&skipcount);
len += iguana_rwnum(1,&msg[len],sizeof(filter),&filter);
len += dragon_rwnum(1,&msg[len],sizeof(skipcount),&skipcount);
len += dragon_rwnum(1,&msg[len],sizeof(filter),&filter);
for (iter=0; iter<3; iter++)
if ( NSPV_req(0,msg,len,NODE_ADDRINDEX,msg[0]>>1) != 0 )
{
@ -646,8 +646,8 @@ UniValue NSPV_addresstxids(char *coinaddr,int32_t CCflag,int32_t skipcount,int32
msg[len++] = slen;
memcpy(&msg[len],coinaddr,slen), len += slen;
msg[len++] = (CCflag != 0);
len += iguana_rwnum(1,&msg[len],sizeof(skipcount),&skipcount);
len += iguana_rwnum(1,&msg[len],sizeof(filter),&filter);
len += dragon_rwnum(1,&msg[len],sizeof(skipcount),&skipcount);
len += dragon_rwnum(1,&msg[len],sizeof(filter),&filter);
//fprintf(stderr,"skipcount.%d\n",skipcount);
for (iter=0; iter<3; iter++)
if ( NSPV_req(0,msg,len,NODE_ADDRINDEX,msg[0]>>1) != 0 )
@ -681,9 +681,9 @@ UniValue NSPV_ccaddresstxids(char *coinaddr,int32_t CCflag,int32_t skipcount,uin
vout=skipcount << 16 | evalcode << 8 | func;
msg[len++] = NSPV_MEMPOOL;
msg[len++] = (CCflag != 0);
len += iguana_rwnum(1,&msg[len],sizeof(funcid),&funcid);
len += iguana_rwnum(1,&msg[len],sizeof(vout),&vout);
len += iguana_rwbignum(1,&msg[len],sizeof(filtertxid),(uint8_t *)&filtertxid);
len += dragon_rwnum(1,&msg[len],sizeof(funcid),&funcid);
len += dragon_rwnum(1,&msg[len],sizeof(vout),&vout);
len += dragon_rwbignum(1,&msg[len],sizeof(filtertxid),(uint8_t *)&filtertxid);
slen = (int32_t)strlen(coinaddr);
msg[len++] = slen;
memcpy(&msg[len],coinaddr,slen), len += slen;
@ -719,9 +719,9 @@ UniValue NSPV_mempooltxids(char *coinaddr,int32_t CCflag,uint8_t funcid,uint256
}
msg[len++] = NSPV_MEMPOOL;
msg[len++] = (CCflag != 0);
len += iguana_rwnum(1,&msg[len],sizeof(funcid),&funcid);
len += iguana_rwnum(1,&msg[len],sizeof(vout),&vout);
len += iguana_rwbignum(1,&msg[len],sizeof(txid),(uint8_t *)&txid);
len += dragon_rwnum(1,&msg[len],sizeof(funcid),&funcid);
len += dragon_rwnum(1,&msg[len],sizeof(vout),&vout);
len += dragon_rwbignum(1,&msg[len],sizeof(txid),(uint8_t *)&txid);
slen = (int32_t)strlen(coinaddr);
msg[len++] = slen;
memcpy(&msg[len],coinaddr,slen), len += slen;
@ -792,7 +792,7 @@ UniValue NSPV_notarizations(int32_t reqheight)
return(NSPV_ntzsresp_json(ptr));
}
msg[len++] = NSPV_NTZS;
len += iguana_rwnum(1,&msg[len],sizeof(reqheight),&reqheight);
len += dragon_rwnum(1,&msg[len],sizeof(reqheight),&reqheight);
for (iter=0; iter<3; iter++)
if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 )
{
@ -819,8 +819,8 @@ UniValue NSPV_txidhdrsproof(uint256 prevtxid,uint256 nexttxid)
}
NSPV_ntzsproofresp_purge(&NSPV_ntzsproofresult);
msg[len++] = NSPV_NTZSPROOF;
len += iguana_rwbignum(1,&msg[len],sizeof(prevtxid),(uint8_t *)&prevtxid);
len += iguana_rwbignum(1,&msg[len],sizeof(nexttxid),(uint8_t *)&nexttxid);
len += dragon_rwbignum(1,&msg[len],sizeof(prevtxid),(uint8_t *)&prevtxid);
len += dragon_rwbignum(1,&msg[len],sizeof(nexttxid),(uint8_t *)&nexttxid);
for (iter=0; iter<3; iter++)
if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 )
{
@ -857,9 +857,9 @@ UniValue NSPV_txproof(int32_t vout,uint256 txid,int32_t height)
}
NSPV_txproof_purge(&NSPV_txproofresult);
msg[len++] = NSPV_TXPROOF;
len += iguana_rwnum(1,&msg[len],sizeof(height),&height);
len += iguana_rwnum(1,&msg[len],sizeof(vout),&vout);
len += iguana_rwbignum(1,&msg[len],sizeof(txid),(uint8_t *)&txid);
len += dragon_rwnum(1,&msg[len],sizeof(height),&height);
len += dragon_rwnum(1,&msg[len],sizeof(vout),&vout);
len += dragon_rwbignum(1,&msg[len],sizeof(txid),(uint8_t *)&txid);
fprintf(stderr,"req txproof %s/v%d at height.%d\n",txid.GetHex().c_str(),vout,height);
for (iter=0; iter<3; iter++)
if ( NSPV_req(0,msg,len,NODE_NSPV,msg[0]>>1) != 0 )
@ -881,8 +881,8 @@ UniValue NSPV_spentinfo(uint256 txid,int32_t vout)
uint8_t msg[512]; int32_t i,iter,len = 0; struct NSPV_spentinfo I;
NSPV_spentinfo_purge(&NSPV_spentresult);
msg[len++] = NSPV_SPENTINFO;
len += iguana_rwnum(1,&msg[len],sizeof(vout),&vout);
len += iguana_rwbignum(1,&msg[len],sizeof(txid),(uint8_t *)&txid);
len += dragon_rwnum(1,&msg[len],sizeof(vout),&vout);
len += dragon_rwbignum(1,&msg[len],sizeof(txid),(uint8_t *)&txid);
for (iter=0; iter<3; iter++)
if ( NSPV_req(0,msg,len,NODE_SPENTINDEX,msg[0]>>1) != 0 )
{
@ -907,8 +907,8 @@ UniValue NSPV_broadcast(char *hex)
txid = NSPV_doublesha256(data,n);
msg = (uint8_t *)malloc(1 + sizeof(txid) + sizeof(n) + n);
msg[len++] = NSPV_BROADCAST;
len += iguana_rwbignum(1,&msg[len],sizeof(txid),(uint8_t *)&txid);
len += iguana_rwnum(1,&msg[len],sizeof(n),&n);
len += dragon_rwbignum(1,&msg[len],sizeof(txid),(uint8_t *)&txid);
len += dragon_rwnum(1,&msg[len],sizeof(n),&n);
memcpy(&msg[len],data,n), len += n;
free(data);
//fprintf(stderr,"send txid.%s\n",txid.GetHex().c_str());
@ -953,14 +953,14 @@ UniValue NSPV_ccmoduleutxos(char *coinaddr, int64_t amount, uint8_t evalcode, st
msg[len++] = slen;
memcpy(&msg[len], coinaddr, slen), len += slen;
len += iguana_rwnum(1, &msg[len], sizeof(amount), &amount);
len += iguana_rwnum(1, &msg[len], sizeof(evalcode), &evalcode);
len += dragon_rwnum(1, &msg[len], sizeof(amount), &amount);
len += dragon_rwnum(1, &msg[len], sizeof(evalcode), &evalcode);
slen = (int32_t)(funcids.size());
msg[len++] = slen;
memcpy(&msg[len], funcids.data(), slen), len += slen;
len += iguana_rwbignum(1, &msg[len], sizeof(filtertxid), (uint8_t *)&filtertxid);
len += dragon_rwbignum(1, &msg[len], sizeof(filtertxid), (uint8_t *)&filtertxid);
for (iter = 0; iter<3; iter++)
if (NSPV_req(0, msg, len, NODE_ADDRINDEX, msg[0] >> 1) != 0)
{

18
src/komodo_pax.h

@ -197,16 +197,16 @@ int32_t dpow_readprices(int32_t height,uint8_t *data,uint32_t *timestampp,double
uint32_t kmdbtc,btcusd,cnyusd; int32_t i,n,nonz,len = 0;
if ( data[0] == 'P' && data[5] == 35 )
data++;
len += iguana_rwnum(0,&data[len],sizeof(uint32_t),(void *)timestampp);
len += iguana_rwnum(0,&data[len],sizeof(uint32_t),(void *)&n);
len += dragon_rwnum(0,&data[len],sizeof(uint32_t),(void *)timestampp);
len += dragon_rwnum(0,&data[len],sizeof(uint32_t),(void *)&n);
if ( n != 35 )
{
printf("dpow_readprices illegal n.%d\n",n);
return(-1);
}
len += iguana_rwnum(0,&data[len],sizeof(uint32_t),(void *)&kmdbtc); // /= 1000
len += iguana_rwnum(0,&data[len],sizeof(uint32_t),(void *)&btcusd); // *= 1000
len += iguana_rwnum(0,&data[len],sizeof(uint32_t),(void *)&cnyusd);
len += dragon_rwnum(0,&data[len],sizeof(uint32_t),(void *)&kmdbtc); // /= 1000
len += dragon_rwnum(0,&data[len],sizeof(uint32_t),(void *)&btcusd); // *= 1000
len += dragon_rwnum(0,&data[len],sizeof(uint32_t),(void *)&cnyusd);
*KMDBTCp = ((double)kmdbtc / (1000000000. * 1000.));
*BTCUSDp = PAX_BTCUSD(height,btcusd);
*CNYUSDp = ((double)cnyusd / 1000000000.);
@ -216,7 +216,7 @@ int32_t dpow_readprices(int32_t height,uint8_t *data,uint32_t *timestampp,double
nonz++;
//else if ( nonz != 0 )
// printf("pvals[%d] is zero\n",i);
len += iguana_rwnum(0,&data[len],sizeof(uint32_t),(void *)&pvals[i]);
len += dragon_rwnum(0,&data[len],sizeof(uint32_t),(void *)&pvals[i]);
//printf("%u ",pvals[i]);
}
/*if ( nonz < n-3 )
@ -249,7 +249,7 @@ int32_t komodo_pax_opreturn(int32_t height,uint8_t *opret,int32_t maxsize)
{
if ( (retval= (int32_t)fread(data,1,fsize,fp)) == fsize )
{
len = iguana_rwnum(0,data,sizeof(crc32),(void *)&crc32);
len = dragon_rwnum(0,data,sizeof(crc32),(void *)&crc32);
check = calc_crc32(0,data+sizeof(crc32),(int32_t)(fsize-sizeof(crc32)));
if ( check == crc32 )
{
@ -301,7 +301,7 @@ int32_t PAX_pubkey(int32_t rwflag,uint8_t *pubkey33,uint8_t *addrtypep,uint8_t r
memset(pubkey33,0,33);
pubkey33[0] = 0x02 | (*shortflagp != 0);
memcpy(&pubkey33[1],fiat,3);
iguana_rwnum(rwflag,&pubkey33[4],sizeof(*fiatoshisp),(void *)fiatoshisp);
dragon_rwnum(rwflag,&pubkey33[4],sizeof(*fiatoshisp),(void *)fiatoshisp);
pubkey33[12] = *addrtypep;
memcpy(&pubkey33[13],rmd160,20);
}
@ -310,7 +310,7 @@ int32_t PAX_pubkey(int32_t rwflag,uint8_t *pubkey33,uint8_t *addrtypep,uint8_t r
*shortflagp = (pubkey33[0] == 0x03);
memcpy(fiat,&pubkey33[1],3);
fiat[3] = 0;
iguana_rwnum(rwflag,&pubkey33[4],sizeof(*fiatoshisp),(void *)fiatoshisp);
dragon_rwnum(rwflag,&pubkey33[4],sizeof(*fiatoshisp),(void *)fiatoshisp);
if ( *shortflagp != 0 )
*fiatoshisp = -(*fiatoshisp);
*addrtypep = pubkey33[12];

14
src/komodo_port.c

@ -727,7 +727,7 @@ void calc_rmd160_sha256(uint8_t rmd160[20],uint8_t *data,int32_t datalen)
calc_rmd160(0,rmd160,hash.bytes,sizeof(hash));
}
int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp)
int32_t dragon_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp)
{
int32_t i; uint64_t x;
if ( rwflag == 0 )
@ -767,7 +767,7 @@ uint32_t komodo_assetmagic(char *symbol,uint64_t supply,uint8_t *extraptr,int32_
uint8_t buf[512]; uint32_t crc0=0; int32_t len = 0; bits256 hash;
if ( strcmp(symbol,"KMD") == 0 )
return(0x8de4eef9);
len = iguana_rwnum(1,&buf[len],sizeof(supply),(void *)&supply);
len = dragon_rwnum(1,&buf[len],sizeof(supply),(void *)&supply);
strcpy((char *)&buf[len],symbol);
len += strlen(symbol);
if ( extraptr != 0 && extralen != 0 )
@ -821,12 +821,12 @@ uint16_t komodo_calcport(char *name,uint64_t supply,uint64_t endsubsidy,uint64_t
//printf("end.%llu reward.%llu halving.%llu decay.%llu perc.%llu\n",(long long)endsubsidy,(long long)reward,(long long)halving,(long long)decay,(long long)commission);
extraptr = extrabuf;
memcpy(extraptr,ASSETCHAINS_OVERRIDE_PUBKEY33,33), extralen = 33;
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(endsubsidy),(void *)&endsubsidy);
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(reward),(void *)&reward);
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(halving),(void *)&halving);
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(decay),(void *)&decay);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(endsubsidy),(void *)&endsubsidy);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(reward),(void *)&reward);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(halving),(void *)&halving);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(decay),(void *)&decay);
val = commission | (((uint64_t)staked & 0xff) << 32) | (((uint64_t)cc & 0xffffff) << 40);
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val);
}
return(komodo_port(name,supply,&ASSETCHAINS_MAGIC,extraptr,extralen));
}

60
src/komodo_utils.h

@ -927,7 +927,7 @@ char *bits256_str(char hexstr[65],bits256 x)
return(hexstr);
}
int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp)
int32_t dragon_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp)
{
int32_t i; uint64_t x;
if ( rwflag == 0 )
@ -962,7 +962,7 @@ int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endian
return(len);
}
int32_t iguana_rwbignum(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *endianedp)
int32_t dragon_rwbignum(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *endianedp)
{
int32_t i;
if ( rwflag == 0 )
@ -1282,7 +1282,7 @@ int32_t queue_size(queue_t *queue)
return count;
}
void iguana_initQ(queue_t *Q,char *name)
void dragon_initQ(queue_t *Q,char *name)
{
struct queueitem *item,*I;
memset(Q,0,sizeof(*Q));
@ -1465,7 +1465,7 @@ uint32_t komodo_assetmagic(char *symbol,uint64_t supply,uint8_t *extraptr,int32_
uint8_t buf[512]; uint32_t crc0=0; int32_t len = 0; bits256 hash;
if ( strcmp(symbol,"KMD") == 0 )
return(0x8de4eef9);
len = iguana_rwnum(1,&buf[len],sizeof(supply),(void *)&supply);
len = dragon_rwnum(1,&buf[len],sizeof(supply),(void *)&supply);
strcpy((char *)&buf[len],symbol);
len += strlen(symbol);
if ( extraptr != 0 && extralen != 0 )
@ -1510,7 +1510,7 @@ uint16_t komodo_port(char *symbol,uint64_t supply,uint32_t *magicp,uint8_t *extr
printf("ports\n");
}*/
char *iguanafmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"iguana\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\",\\\"sapling\\\":1,\\\"notarypay\\\":%i}\"";
char *dragonfmtstr = (char *)"curl --url \"http://127.0.0.1:7776\" --data \"{\\\"conf\\\":\\\"%s.conf\\\",\\\"path\\\":\\\"${HOME#\"/\"}/.komodo/%s\\\",\\\"unitval\\\":\\\"20\\\",\\\"zcash\\\":1,\\\"RELAY\\\":-1,\\\"VALIDATE\\\":0,\\\"prefetchlag\\\":-1,\\\"poll\\\":100,\\\"active\\\":1,\\\"agent\\\":\\\"dragon\\\",\\\"method\\\":\\\"addcoin\\\",\\\"startpend\\\":4,\\\"endpend\\\":4,\\\"services\\\":129,\\\"maxpeers\\\":8,\\\"newcoin\\\":\\\"%s\\\",\\\"name\\\":\\\"%s\\\",\\\"hasheaders\\\":1,\\\"useaddmultisig\\\":0,\\\"netmagic\\\":\\\"%s\\\",\\\"p2p\\\":%u,\\\"rpc\\\":%u,\\\"pubval\\\":60,\\\"p2shval\\\":85,\\\"wifval\\\":188,\\\"txfee_satoshis\\\":\\\"10000\\\",\\\"isPoS\\\":0,\\\"minoutput\\\":10000,\\\"minconfirms\\\":2,\\\"genesishash\\\":\\\"027e3758c3a65b12aa1046462b486d0a63bfa1beae327897f56c5cfb7daaae71\\\",\\\"protover\\\":170002,\\\"genesisblock\\\":\\\"0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a000000000000000000000000000000000000000000000000000000000000000029ab5f490f0f0f200b00000000000000000000000000000000000000000000000000000000000000fd4005000d5ba7cda5d473947263bf194285317179d2b0d307119c2e7cc4bd8ac456f0774bd52b0cd9249be9d40718b6397a4c7bbd8f2b3272fed2823cd2af4bd1632200ba4bf796727d6347b225f670f292343274cc35099466f5fb5f0cd1c105121b28213d15db2ed7bdba490b4cedc69742a57b7c25af24485e523aadbb77a0144fc76f79ef73bd8530d42b9f3b9bed1c135ad1fe152923fafe98f95f76f1615e64c4abb1137f4c31b218ba2782bc15534788dda2cc08a0ee2987c8b27ff41bd4e31cd5fb5643dfe862c9a02ca9f90c8c51a6671d681d04ad47e4b53b1518d4befafefe8cadfb912f3d03051b1efbf1dfe37b56e93a741d8dfd80d576ca250bee55fab1311fc7b3255977558cdda6f7d6f875306e43a14413facdaed2f46093e0ef1e8f8a963e1632dcbeebd8e49fd16b57d49b08f9762de89157c65233f60c8e38a1f503a48c555f8ec45dedecd574a37601323c27be597b956343107f8bd80f3a925afaf30811df83c402116bb9c1e5231c70fff899a7c82f73c902ba54da53cc459b7bf1113db65cc8f6914d3618560ea69abd13658fa7b6af92d374d6eca9529f8bd565166e4fcbf2a8dfb3c9b69539d4d2ee2e9321b85b331925df195915f2757637c2805e1d4131e1ad9ef9bc1bb1c732d8dba4738716d351ab30c996c8657bab39567ee3b29c6d054b711495c0d52e1cd5d8e55b4f0f0325b97369280755b46a02afd54be4ddd9f77c22272b8bbb17ff5118fedbae2564524e797bd28b5f74f7079d532ccc059807989f94d267f47e724b3f1ecfe00ec9e6541c961080d8891251b84b4480bc292f6a180bea089fef5bbda56e1e41390d7c0e85ba0ef530f7177413481a226465a36ef6afe1e2bca69d2078712b3912bba1a99b1fbff0d355d6ffe726d2bb6fbc103c4ac5756e5bee6e47e17424ebcbf1b63d8cb90ce2e40198b4f4198689daea254307e52a25562f4c1455340f0ffeb10f9d8e914775e37d0edca019fb1b9c6ef81255ed86bc51c5391e0591480f66e2d88c5f4fd7277697968656a9b113ab97f874fdd5f2465e5559533e01ba13ef4a8f7a21d02c30c8ded68e8c54603ab9c8084ef6d9eb4e92c75b078539e2ae786ebab6dab73a09e0aa9ac575bcefb29e930ae656e58bcb513f7e3c17e079dce4f05b5dbc18c2a872b22509740ebe6a3903e00ad1abc55076441862643f93606e3dc35e8d9f2caef3ee6be14d513b2e062b21d0061de3bd56881713a1a5c17f5ace05e1ec09da53f99442df175a49bd154aa96e4949decd52fed79ccf7ccbce32941419c314e374e4a396ac553e17b5340336a1a25c22f9e42a243ba5404450b650acfc826a6e432971ace776e15719515e1634ceb9a4a35061b668c74998d3dfb5827f6238ec015377e6f9c94f38108768cf6e5c8b132e0303fb5a200368f845ad9d46343035a6ff94031df8d8309415bb3f6cd5ede9c135fdabcc030599858d803c0f85be7661c88984d88faa3d26fb0e9aac0056a53f1b5d0baed713c853c4a2726869a0a124a8a5bbc0fc0ef80c8ae4cb53636aa02503b86a1eb9836fcc259823e2692d921d88e1ffc1e6cb2bde43939ceb3f32a611686f539f8f7c9f0bf00381f743607d40960f06d347d1cd8ac8a51969c25e37150efdf7aa4c2037a2fd0516fb444525ab157a0ed0a7412b2fa69b217fe397263153782c0f64351fbdf2678fa0dc8569912dcd8e3ccad38f34f23bbbce14c6a26ac24911b308b82c7e43062d180baeac4ba7153858365c72c63dcf5f6a5b08070b730adb017aeae925b7d0439979e2679f45ed2f25a7edcfd2fb77a8794630285ccb0a071f5cce410b46dbf9750b0354aae8b65574501cc69efb5b6a43444074fee116641bb29da56c2b4a7f456991fc92b2\\\",\\\"debug\\\":0,\\\"seedipaddr\\\":\\\"%s\\\",\\\"sapling\\\":1,\\\"notarypay\\\":%i}\"";
@ -2162,58 +2162,58 @@ void komodo_args(char *argv0)
(long long)ASSETCHAINS_NOTARY_PAY[i]);
// TODO: Verify that we don't overrun extrabuf here, which is a 256 byte buffer
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_ENDSUBSIDY[i]),(void *)&ASSETCHAINS_ENDSUBSIDY[i]);
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_REWARD[i]),(void *)&ASSETCHAINS_REWARD[i]);
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_HALVING[i]),(void *)&ASSETCHAINS_HALVING[i]);
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_DECAY[i]),(void *)&ASSETCHAINS_DECAY[i]);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_ENDSUBSIDY[i]),(void *)&ASSETCHAINS_ENDSUBSIDY[i]);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_REWARD[i]),(void *)&ASSETCHAINS_REWARD[i]);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_HALVING[i]),(void *)&ASSETCHAINS_HALVING[i]);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_DECAY[i]),(void *)&ASSETCHAINS_DECAY[i]);
if ( ASSETCHAINS_NOTARY_PAY[0] != 0 )
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NOTARY_PAY[i]),(void *)&ASSETCHAINS_NOTARY_PAY[i]);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NOTARY_PAY[i]),(void *)&ASSETCHAINS_NOTARY_PAY[i]);
}
if (ASSETCHAINS_LASTERA > 0)
{
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_LASTERA),(void *)&ASSETCHAINS_LASTERA);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_LASTERA),(void *)&ASSETCHAINS_LASTERA);
}
// hash in lock above for time locked coinbase transactions above a certain reward value only if the lock above
// param was specified, otherwise, for compatibility, do nothing
if ( ASSETCHAINS_TIMELOCKGTE != _ASSETCHAINS_TIMELOCKOFF )
{
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_TIMELOCKGTE),(void *)&ASSETCHAINS_TIMELOCKGTE);
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_TIMEUNLOCKFROM),(void *)&ASSETCHAINS_TIMEUNLOCKFROM);
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_TIMEUNLOCKTO),(void *)&ASSETCHAINS_TIMEUNLOCKTO);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_TIMELOCKGTE),(void *)&ASSETCHAINS_TIMELOCKGTE);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_TIMEUNLOCKFROM),(void *)&ASSETCHAINS_TIMEUNLOCKFROM);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_TIMEUNLOCKTO),(void *)&ASSETCHAINS_TIMEUNLOCKTO);
}
if ( ASSETCHAINS_ALGO != ASSETCHAINS_EQUIHASH )
{
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_ALGO),(void *)&ASSETCHAINS_ALGO);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_ALGO),(void *)&ASSETCHAINS_ALGO);
}
if ( ASSETCHAINS_LWMAPOS != 0 )
{
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_LWMAPOS),(void *)&ASSETCHAINS_LWMAPOS);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_LWMAPOS),(void *)&ASSETCHAINS_LWMAPOS);
}
val = ASSETCHAINS_COMMISSION | (((int64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | ((ASSETCHAINS_PUBLIC != 0) << 7) | ((ASSETCHAINS_PRIVATE != 0) << 6) | ASSETCHAINS_TXPOW;
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val);
if ( ASSETCHAINS_FOUNDERS != 0 )
{
uint8_t tmp = 1;
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(tmp),(void *)&tmp);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(tmp),(void *)&tmp);
if ( ASSETCHAINS_FOUNDERS > 1 )
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS),(void *)&ASSETCHAINS_FOUNDERS);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS),(void *)&ASSETCHAINS_FOUNDERS);
if ( ASSETCHAINS_FOUNDERS_REWARD != 0 )
{
fprintf(stderr, "set founders reward.%lld\n",(long long)ASSETCHAINS_FOUNDERS_REWARD);
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS_REWARD),(void *)&ASSETCHAINS_FOUNDERS_REWARD);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS_REWARD),(void *)&ASSETCHAINS_FOUNDERS_REWARD);
}
}
if ( ASSETCHAINS_SCRIPTPUB.size() > 1 )
{
decode_hex(&extraptr[extralen],ASSETCHAINS_SCRIPTPUB.size()/2,(char *)ASSETCHAINS_SCRIPTPUB.c_str());
extralen += ASSETCHAINS_SCRIPTPUB.size()/2;
//extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str());
//extralen += dragon_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str());
fprintf(stderr,"append ac_script %s\n",ASSETCHAINS_SCRIPTPUB.c_str());
}
if ( ASSETCHAINS_SELFIMPORT.size() > 0 )
@ -2246,7 +2246,7 @@ fprintf(stderr,"extralen.%d before disable bits\n",extralen);
fprintf(stderr," <- CCLIB name\n");
}
if ( ASSETCHAINS_BLOCKTIME != 60 )
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_BLOCKTIME),(void *)&ASSETCHAINS_BLOCKTIME);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_BLOCKTIME),(void *)&ASSETCHAINS_BLOCKTIME);
if ( Mineropret.size() != 0 )
{
for (i=0; i<Mineropret.size(); i++)
@ -2254,7 +2254,7 @@ fprintf(stderr,"extralen.%d before disable bits\n",extralen);
}
if ( ASSETCHAINS_CBOPRET != 0 )
{
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_CBOPRET),(void *)&ASSETCHAINS_CBOPRET);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_CBOPRET),(void *)&ASSETCHAINS_CBOPRET);
if ( ASSETCHAINS_PRICES.size() != 0 )
{
for (i=0; i<ASSETCHAINS_PRICES.size(); i++)
@ -2279,20 +2279,20 @@ fprintf(stderr,"extralen.%d before disable bits\n",extralen);
}
if ( ASSETCHAINS_NK[0] != 0 && ASSETCHAINS_NK[1] != 0 )
{
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NK[0]),(void *)&ASSETCHAINS_NK[0]);
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NK[1]),(void *)&ASSETCHAINS_NK[1]);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NK[0]),(void *)&ASSETCHAINS_NK[0]);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_NK[1]),(void *)&ASSETCHAINS_NK[1]);
}
if ( KOMODO_SNAPSHOT_INTERVAL != 0 )
{
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(KOMODO_SNAPSHOT_INTERVAL),(void *)&KOMODO_SNAPSHOT_INTERVAL);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(KOMODO_SNAPSHOT_INTERVAL),(void *)&KOMODO_SNAPSHOT_INTERVAL);
}
if ( ASSETCHAINS_EARLYTXIDCONTRACT != 0 )
{
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_EARLYTXIDCONTRACT),(void *)&ASSETCHAINS_EARLYTXIDCONTRACT);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_EARLYTXIDCONTRACT),(void *)&ASSETCHAINS_EARLYTXIDCONTRACT);
}
if ( ASSETCHAINS_CBMATURITY != 0 )
{
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_CBMATURITY),(void *)&ASSETCHAINS_CBMATURITY);
extralen += dragon_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_CBMATURITY),(void *)&ASSETCHAINS_CBMATURITY);
}
if ( ASSETCHAINS_ADAPTIVEPOW != 0 )
extraptr[extralen++] = ASSETCHAINS_ADAPTIVEPOW;
@ -2363,7 +2363,7 @@ fprintf(stderr,"extralen.%d before disable bits\n",extralen);
ASSETCHAINS_RPCPORT = ASSETCHAINS_P2PPORT + 1;
//ASSETCHAINS_NOTARIES = GetArg("-ac_notaries","");
//komodo_assetchain_pubkeys((char *)ASSETCHAINS_NOTARIES.c_str());
iguana_rwnum(1,magic,sizeof(ASSETCHAINS_MAGIC),(void *)&ASSETCHAINS_MAGIC);
dragon_rwnum(1,magic,sizeof(ASSETCHAINS_MAGIC),(void *)&ASSETCHAINS_MAGIC);
for (i=0; i<4; i++)
sprintf(&magicstr[i<<1],"%02x",magic[i]);
magicstr[8] = 0;
@ -2374,7 +2374,7 @@ fprintf(stderr,"extralen.%d before disable bits\n",extralen);
int8_t notarypay = 0;
if ( ASSETCHAINS_NOTARY_PAY[0] != 0 )
notarypay = 1;
fprintf(fp,iguanafmtstr,name.c_str(),name.c_str(),name.c_str(),name.c_str(),magicstr,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,"78.47.196.146",notarypay);
fprintf(fp,dragonfmtstr,name.c_str(),name.c_str(),name.c_str(),name.c_str(),magicstr,ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT,"78.47.196.146",notarypay);
fclose(fp);
//printf("created (%s)\n",fname);
} else printf("error creating (%s)\n",fname);

4
src/notaries_staked.h

@ -5,10 +5,10 @@
#include "crosschain.h"
#include "cc/CCinclude.h"
static const int32_t iguanaPort = 9333;
static const int32_t dragonPort = 9333;
static const int8_t BTCminsigs = 13;
static const int8_t overrideMinSigs = 7;
static const char *iguanaSeeds[8][1] =
static const char *dragonSeeds[8][1] =
{
{"94.23.1.95"},
{"103.6.12.112"},

10
src/rpc/misc.cpp

@ -98,10 +98,10 @@ int32_t getera(int timestamp)
return(0);
}
UniValue getiguanajson(const UniValue& params, bool fHelp, const CPubKey& mypk)
UniValue getdragonjson(const UniValue& params, bool fHelp, const CPubKey& mypk)
{
if (fHelp || params.size() != 0)
throw runtime_error("getiguanajson\nreturns json for iguana, for the current ERA.");
throw runtime_error("getdragonjson\nreturns json for dragon, for the current ERA.");
UniValue json(UniValue::VOBJ);
UniValue seeds(UniValue::VARR);
@ -113,7 +113,7 @@ UniValue getiguanajson(const UniValue& params, bool fHelp, const CPubKey& mypk)
// loop over seeds array and push back to json array for seeds
for (int8_t i = 0; i < 8; i++) {
seeds.push_back(iguanaSeeds[i][0]);
seeds.push_back(dragonSeeds[i][0]);
}
// loop over era's notaries and push back each pair to the notary array
@ -123,14 +123,14 @@ UniValue getiguanajson(const UniValue& params, bool fHelp, const CPubKey& mypk)
notaries.push_back(notary);
}
// get the min sigs .. this always rounds UP so min sigs in iguana is +1 min sigs in komodod, due to some rounding error.
// get the min sigs .. this always rounds UP so min sigs in dragon is +1 min sigs in komodod, due to some rounding error.
int minsigs;
if ( num_notaries_STAKED[era]/5 > overrideMinSigs )
minsigs = (num_notaries_STAKED[era] / 5) + 1;
else
minsigs = overrideMinSigs;
json.push_back(Pair("port",iguanaPort));
json.push_back(Pair("port",dragonPort));
json.push_back(Pair("BTCminsigs",BTCminsigs));
json.push_back(Pair("minsigs",minsigs));
json.push_back(Pair("seeds",seeds));

2
src/rpc/server.cpp

@ -298,7 +298,7 @@ static const CRPCCommand vRPCCommands[] =
// --------------------- ------------------------ ----------------------- ----------
/* Overall control/query calls */
{ "control", "help", &help, true },
{ "control", "getiguanajson", &getiguanajson, true },
{ "control", "getdragonjson", &getdragonjson, true },
{ "control", "getnotarysendmany", &getnotarysendmany, true },
{ "control", "geterablockheights", &geterablockheights, true },
{ "control", "stop", &stop, true },

2
src/rpc/server.h

@ -391,7 +391,7 @@ extern UniValue validateaddress(const UniValue& params, bool fHelp, const CPubKe
extern UniValue txnotarizedconfirmed(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue decodeccopret(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue getinfo(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue getiguanajson(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue getdragonjson(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue getnotarysendmany(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue geterablockheights(const UniValue& params, bool fHelp, const CPubKey& mypk);
extern UniValue setpubkey(const UniValue& params, bool fHelp, const CPubKey& mypk);

16
src/wallet/rpcwallet.cpp

@ -587,7 +587,7 @@ int32_t komodo_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_
extern int32_t KOMODO_PAX;
extern uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE;
int32_t komodo_is_issuer();
int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp);
int32_t dragon_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp);
int32_t komodo_isrealtime(int32_t *kmdheightp);
int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base);
int32_t komodo_kvsearch(uint256 *refpubkeyp,int32_t current_height,uint32_t *flagsp,int32_t *heightp,uint8_t value[IGUANA_MAXSCRIPTSIZE],uint8_t *key,int32_t keylen);
@ -703,10 +703,10 @@ UniValue kvupdate(const UniValue& params, bool fHelp, const CPubKey& mypk)
ret.push_back(Pair("value",params[1].get_str()));
ret.push_back(Pair("valuesize",valuesize));
}
iguana_rwnum(1,&keyvalue[0],sizeof(keylen),&keylen);
iguana_rwnum(1,&keyvalue[2],sizeof(valuesize),&valuesize);
iguana_rwnum(1,&keyvalue[4],sizeof(height),&height);
iguana_rwnum(1,&keyvalue[8],sizeof(flags),&flags);
dragon_rwnum(1,&keyvalue[0],sizeof(keylen),&keylen);
dragon_rwnum(1,&keyvalue[2],sizeof(valuesize),&valuesize);
dragon_rwnum(1,&keyvalue[4],sizeof(height),&height);
dragon_rwnum(1,&keyvalue[8],sizeof(flags),&flags);
memcpy(&keyvalue[12],key,keylen);
if ( value != 0 )
memcpy(&keyvalue[12 + keylen],value,valuesize);
@ -780,7 +780,7 @@ UniValue paxdeposit(const UniValue& params, bool fHelp, const CPubKey& mypk)
uint8_t opretbuf[64]; int32_t opretlen; uint64_t fee = komodoshis / 1000;
if ( fee < 10000 )
fee = 10000;
iguana_rwnum(1,&pubkey37[33],sizeof(height),&height);
dragon_rwnum(1,&pubkey37[33],sizeof(height),&height);
opretlen = komodo_opreturnscript(opretbuf,'D',pubkey37,37);
SendMoney(address.Get(),fee,fSubtractFeeFromAmount,wtx,opretbuf,opretlen,komodoshis);
return wtx.GetHash().GetHex();
@ -815,7 +815,7 @@ UniValue paxwithdraw(const UniValue& params, bool fHelp, const CPubKey& mypk)
uint8_t opretbuf[64]; int32_t opretlen; uint64_t fee = fiatoshis / 1000;
if ( fee < 10000 )
fee = 10000;
iguana_rwnum(1,&pubkey37[33],sizeof(kmdheight),&kmdheight);
dragon_rwnum(1,&pubkey37[33],sizeof(kmdheight),&kmdheight);
opretlen = komodo_opreturnscript(opretbuf,'W',pubkey37,37);
SendMoney(destaddress.Get(),fee,fSubtractFeeFromAmount,wtx,opretbuf,opretlen,fiatoshis);
return wtx.GetHash().GetHex();
@ -5196,7 +5196,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp
+ strprintf("%d", MERGE_TO_ADDRESS_DEFAULT_TRANSPARENT_LIMIT) + ") Limit on the maximum number of UTXOs to merge. Set to 0 to use node option -mempooltxinputlimit (before Overwinter), or as many as will fit in the transaction (after Overwinter).\n"
"4. shielded_limit (numeric, optional, default="
+ strprintf("%d Sapling Notes", MERGE_TO_ADDRESS_DEFAULT_SAPLING_LIMIT) + ") Limit on the maximum number of notes to merge. Set to 0 to merge as many as will fit in the transaction.\n"
"5. maximum_utxo_size (numeric, optional) eg, 0.0001 anything under 10000 satoshies will be merged, ignores 10,000 sat p2pk utxo that iguana uses, and merges coinbase utxo.\n"
"5. maximum_utxo_size (numeric, optional) eg, 0.0001 anything under 10000 satoshies will be merged, ignores 10,000 sat p2pk utxo that dragon uses, and merges coinbase utxo.\n"
"6. \"memo\" (string, optional) Encoded as hex. When toaddress is a z-addr, this will be stored in the memo field of the new note.\n"
"\nResult:\n"

Loading…
Cancel
Save