Browse Source

sapling param added to json

- added sapling param in `struct iguana_info`
- each coin now have coin->sapling param (sapling=0 - sapling disabled, sapling !=0 - sapling enabled), we can set "sapling":1 in JSON when calling "addcoin" method.
- removed hardcoded "VRSC" and "VRSCTEST", now we should use "sapling" param in "addcoin" method
- removed unused zcash param in bitcoin_sigtxid
blackjok3r
DeckerSU 6 years ago
parent
commit
739b67f0a6
  1. 2
      basilisk/basilisk_bitcoin.c
  2. 4
      iguana/dpow/dpow_rpc.c
  3. 7
      iguana/dpow/dpow_tx.c
  4. 11
      iguana/iguana777.c
  5. 21
      iguana/iguana_sign.c
  6. 2
      includes/iguana_structs.h

2
basilisk/basilisk_bitcoin.c

@ -595,7 +595,7 @@ char *iguana_utxoduplicates(struct supernet_info *myinfo,struct iguana_info *coi
printf("%s txfee %.8f\n", coin->symbol, dstr(txfee));
uint32_t txversion = 1; // txversion = 1 for non-overwintered and non-sapling coins
if (strcmp(coin->symbol, "VRSC") == 0 || strcmp(coin->symbol, "VRSCTEST") == 0)
if (coin->sapling != 0)
txversion = 4;
if ( (txobj= bitcoin_txcreate(coin->symbol,coin->chain->isPoS,0,txversion,0)) != 0 )

4
iguana/dpow/dpow_rpc.c

@ -647,8 +647,8 @@ char *dpow_signrawtransaction(struct supernet_info *myinfo,struct iguana_info *c
free_json(retjson);
}
//printf("%s signrawtransaction.(%s) params.(%s)\n",coin->symbol,retstr,paramstr);
uint32_t zcash = (strcmp(coin->symbol, "VRSC") == 0 || strcmp(coin->symbol, "VRSCTEST") == 0);
/*if (zcash)
/*if (coin->sapling != 0)
printf("[Decker] %s dpow_signrawtransaction.(%s) params.(%s)\n", coin->symbol, retstr, paramstr);*/
free(paramstr);
usleep(10000);

7
iguana/dpow/dpow_tx.c

@ -270,7 +270,6 @@ bits256 dpow_notarytx(struct supernet_info *myinfo,char *signedtx,int32_t *numsi
// int32_t preimage_len; uint8_t preimage[32768]; // here we will create preimage, when usesigs=0 (?)
struct iguana_info *coin = (src_or_dest != 0) ? bp->destcoin : bp->srccoin;
uint32_t zcash = (strcmp(coin->symbol, "VRSC") == 0 || strcmp(coin->symbol, "VRSCTEST") == 0);
//printf("[Decker] dpow_notarytx: src.(%s) dst.(%s) src_or_dest.(%d) usesigs.(%d)\n", bp->srccoin->symbol, bp->destcoin->symbol, src_or_dest, usesigs);
signedtx[0] = 0;
@ -279,14 +278,14 @@ bits256 dpow_notarytx(struct supernet_info *myinfo,char *signedtx,int32_t *numsi
len = numsigs = 0;
version = 1;
if (zcash) {
if (coin->sapling != 0) {
version = 4;
version = 1 << 31 | version; // overwintered
}
len += iguana_rwnum(1,&serialized[len],sizeof(version),&version);
if (zcash) {
if (coin->sapling != 0) {
uint32_t versiongroupid = 0x892f2085; // sapling
len += iguana_rwnum(1, &serialized[len], sizeof(versiongroupid), &versiongroupid);
}
@ -370,7 +369,7 @@ bits256 dpow_notarytx(struct supernet_info *myinfo,char *signedtx,int32_t *numsi
}
len += n;
if (zcash) {
if (coin->sapling != 0) {
uint32_t nExpiryHeight = 0;
uint64_t valueBalance = 0;
uint8_t nShieldedSpend = 0;

11
iguana/iguana777.c

@ -1066,6 +1066,7 @@ void iguana_nameset(char name[64],char *symbol,cJSON *json)
struct iguana_info *iguana_setcoin(char *symbol,void *launched,int32_t maxpeers,int64_t maxrecvcache,uint64_t services,int32_t initialheight,int32_t maphash,int32_t minconfirms,int32_t maxrequests,int32_t maxbundles,cJSON *json,int32_t virtcoin)
{
// printf("[Decker] iguana_setcoin: [%s] %s", symbol, cJSON_Print(json));
struct iguana_chain *iguana_createchain(cJSON *json);
struct supernet_info *myinfo = SuperNET_MYINFO(0);
struct iguana_info *coin; int32_t j,m,mult,maxval,mapflags; char name[64]; cJSON *peers;
@ -1134,7 +1135,15 @@ struct iguana_info *iguana_setcoin(char *symbol,void *launched,int32_t maxpeers,
coin->enableCACHE = 1;//0;//(strcmp("BTCD",coin->symbol) == 0);
if ( jobj(json,"cache") != 0 )
coin->enableCACHE = juint(json,"cache");
if ( (coin->polltimeout= juint(json,"poll")) <= 0 )
coin->sapling = 0;
if (jobj(json, "sapling") != 0)
{
coin->sapling = juint(json, "sapling");
printf("[Decker] %s sapling = %d\n", symbol, coin->sapling);
}
if ( (coin->polltimeout= juint(json,"poll")) <= 0 )
coin->polltimeout = IGUANA_DEFAULT_POLLTIMEOUT;
coin->active = juint(json,"active");
if ( (coin->minconfirms= minconfirms) == 0 )

21
iguana/iguana_sign.c

@ -505,9 +505,7 @@ cJSON *iguana_voutjson(struct iguana_info *coin,struct iguana_msgvout *vout,int3
return(json);
}
// TODO: with changes it bitcoin_sigtxid need additionally check bitcoin_verifyvins (!)
// Old args: bits256 bitcoin_sigtxid(struct iguana_info *coin,int32_t height,uint8_t *serialized,int32_t maxlen,struct iguana_msgtx *msgtx,int32_t vini,uint8_t *spendscript,int32_t spendlen,int32_t hashtype,char *vpnstr,int32_t suppress_pubkeys)
bits256 bitcoin_sigtxid(struct iguana_info *coin, int32_t height, uint8_t *serialized, int32_t maxlen, struct iguana_msgtx *msgtx, int32_t vini, uint8_t *spendscript, int32_t spendlen, uint64_t spendamount, int32_t hashtype, char *vpnstr, int32_t suppress_pubkeys, int32_t zcash)
bits256 bitcoin_sigtxid(struct iguana_info *coin, int32_t height, uint8_t *serialized, int32_t maxlen, struct iguana_msgtx *msgtx, int32_t vini, uint8_t *spendscript, int32_t spendlen, uint64_t spendamount, int32_t hashtype, char *vpnstr, int32_t suppress_pubkeys)
{
int32_t i,len; bits256 sigtxid,txid,revsigtxid; struct iguana_msgtx dest;
dest = *msgtx;
@ -728,14 +726,12 @@ int32_t iguana_rwmsgtx(struct iguana_info *coin,int32_t height,int32_t rwflag,cJ
{
int32_t i,n,len = 0,extraused=0; uint8_t spendscript[IGUANA_MAXSCRIPTSIZE],*txstart = serialized,*sigser=0; char txidstr[65]; uint64_t spendamount; cJSON *vinarray=0,*voutarray=0; bits256 sigtxid;
uint32_t zcash = (strcmp(coin->symbol, "VRSC") == 0 || strcmp(coin->symbol, "VRSCTEST") == 0); // we definitely need to determine somehow zcash-based coins here instead of compare coin names
len += iguana_rwnum(rwflag,&serialized[len],sizeof(msg->version),&msg->version);
len += iguana_rwnum(rwflag,&serialized[len],sizeof(msg->version),&msg->version);
uint32_t overwintered = msg->version >> 31;
uint32_t version = msg->version;
// for version 4 the ZK proof size is 192, otherwise 296
uint32_t zksnark_proof_size = ZKSNARK_PROOF_SIZE;
if (zcash) {
if (coin->sapling != 0) {
if (overwintered) {
version = msg->version & 0x7FFFFFFF;
len += iguana_rwnum(rwflag, &serialized[len], sizeof(msg->version_group_id), &msg->version_group_id);
@ -843,7 +839,7 @@ int32_t iguana_rwmsgtx(struct iguana_info *coin,int32_t height,int32_t rwflag,cJ
}
len += iguana_rwnum(rwflag,&serialized[len],sizeof(msg->lock_time),&msg->lock_time);
if (zcash && overwintered) {
if ((coin->sapling !=0) && overwintered) {
len += iguana_rwnum(rwflag, &serialized[len], sizeof(msg->expiry_height), &msg->expiry_height);
if (json != 0) {
jaddnum(json, "expiryheight", msg->expiry_height);
@ -959,7 +955,7 @@ int32_t iguana_rwmsgtx(struct iguana_info *coin,int32_t height,int32_t rwflag,cJ
}
//printf("lock_time.%08x len.%d\n",msg->lock_time,len);
if (zcash == LP_IS_ZCASHPROTOCOL && msg->version > 1)
if ((coin->sapling != 0) && msg->version > 1)
{
struct iguana_msgjoinsplit joinsplit; uint8_t joinsplitpubkey[33], joinsplitsig[64];
len += iguana_rwnum(rwflag, &serialized[len], sizeof(msg->numjoinsplits), &msg->numjoinsplits);
@ -982,7 +978,7 @@ int32_t iguana_rwmsgtx(struct iguana_info *coin,int32_t height,int32_t rwflag,cJ
}
}
}
if (zcash == 1 && msg->version >= 4 && !(msg->shielded_spend_num == 0 && msg->shielded_output_num == 0)) {
if ((coin->sapling != 0) && msg->version >= 4 && !(msg->shielded_spend_num == 0 && msg->shielded_output_num == 0)) {
if (rwflag == 1) {
memcpy(&serialized[len], msg->binding_sig, 64), len += 64;
}
@ -1034,7 +1030,7 @@ int32_t iguana_rwmsgtx(struct iguana_info *coin,int32_t height,int32_t rwflag,cJ
//printf("spendamount = %.8f\n", dstr(spendamount));
free(jtxout);
sigtxid = bitcoin_sigtxid(coin,height,sigser,maxsize*2,msg,i,msg->vins[i].spendscript,msg->vins[i].spendlen,spendamount, SIGHASH_ALL,vpnstr,suppress_pubkeys, zcash);
sigtxid = bitcoin_sigtxid(coin,height,sigser,maxsize*2,msg,i,msg->vins[i].spendscript,msg->vins[i].spendlen,spendamount, SIGHASH_ALL,vpnstr,suppress_pubkeys);
// printf("after vini.%d vinscript.%p spendscript.%p spendlen.%d (%s)\n",i,msg->vins[i].vinscript,msg->vins[i].spendscript,msg->vins[i].spendlen,jprint(jitem(vins,i),0));
if ( iguana_vinarray_check(vinarray,msg->vins[i].prev_hash,msg->vins[i].prev_vout) < 0 )
jaddi(vinarray,iguana_vinjson(coin,&msg->vins[i],sigtxid));
@ -1349,7 +1345,6 @@ int32_t bitcoin_verifyvins(struct iguana_info *coin,int32_t height,bits256 *sign
scriptlen = msgtx->vins[vini].spendlen;
}
uint32_t zcash = (strcmp(coin->symbol, "VRSC") == 0 || strcmp(coin->symbol, "VRSCTEST") == 0); // we definitely need to determine somehow zcash-based coins here instead of compare coin names
struct supernet_info *myinfo = SuperNET_MYINFO(0); cJSON *jtxout = 0;
jtxout = dpow_gettxout(0, coin, msgtx->vins[vini].prev_hash, msgtx->vins[vini].prev_vout);
spendamount = jdouble(jtxout, "value") * SATOSHIDEN;
@ -1357,7 +1352,7 @@ int32_t bitcoin_verifyvins(struct iguana_info *coin,int32_t height,bits256 *sign
//printf("spendamount = %.8f\n", dstr(spendamount));
free(jtxout);
sigtxid = bitcoin_sigtxid(coin,height,serialized,maxlen,msgtx,vini,script,scriptlen,spendamount,sighash,vpnstr,suppress_pubkeys,zcash);
sigtxid = bitcoin_sigtxid(coin,height,serialized,maxlen,msgtx,vini,script,scriptlen,spendamount,sighash,vpnstr,suppress_pubkeys);
if ( bits256_nonz(sigtxid) != 0 )
{
vp = &V[vini];

2
includes/iguana_structs.h

@ -522,7 +522,7 @@ struct iguana_info
uint32_t fastfind; FILE *fastfps[0x100]; uint8_t *fast[0x100]; int32_t *fasttables[0x100]; long fastsizes[0x100];
uint64_t instance_nonce,myservices,totalsize,totalrecv,totalpackets,sleeptime;
int64_t mining,totalfees,TMPallocated,MAXRECVCACHE,MAXMEM,PREFETCHLAG,estsize,activebundles;
int32_t MoMoMheight,MAXPEERS,MAXPENDINGREQUESTS,MAXBUNDLES,MAXSTUCKTIME,active,closestbundle,numemitted,lastsweep,numemit,startutc,newramchain,numcached,cachefreed,helperdepth,startPEND,endPEND,enableCACHE,FULLNODE,VALIDATENODE,origbalanceswritten,balanceswritten,lastRTheight,RTdatabad;
int32_t MoMoMheight,MAXPEERS,MAXPENDINGREQUESTS,MAXBUNDLES,MAXSTUCKTIME,active,closestbundle,numemitted,lastsweep,numemit,startutc,newramchain,numcached,cachefreed,helperdepth,startPEND,endPEND,enableCACHE,FULLNODE,VALIDATENODE,origbalanceswritten,balanceswritten,lastRTheight,RTdatabad,sapling;
bits256 balancehash,allbundles;
uint32_t lastsync,parsetime,numiAddrs,lastpossible,bundlescount,savedblocks,backlog,spendvectorsaved,laststats,lastinv2,symbolcrc,spendvalidated; char VALIDATEDIR[512];
int32_t longestchain,badlongestchain,longestchain_strange,RTramchain_busy,emitbusy,stuckiters,virtualchain,RTheight,RTreset_needed;

Loading…
Cancel
Save