Browse Source

redundant dex* queries, iguana lock time

etomic
jl777 8 years ago
parent
commit
c9a93218f9
  1. 2
      basilisk/basilisk_MSG.c
  2. 4
      basilisk/basilisk_bitcoin.c
  3. 2
      basilisk/basilisk_swap.c
  4. 2
      gecko/gecko_miner.c
  5. 2
      iguana/dPoW.h
  6. 99
      iguana/dpow/dpow_network.c
  7. 2
      iguana/iguana_notary.c
  8. 2
      iguana/iguana_payments.c
  9. 6
      iguana/iguana_sign.c
  10. 2
      iguana/tests/dexgetH
  11. 2
      iguana/tests/dexlistunspent
  12. 2
      includes/iguana_funcs.h

2
basilisk/basilisk_MSG.c

@ -309,7 +309,7 @@ HASH_ARRAY_STRING(basilisk,sendmessage,hash,vals,hexstr)
memcpy(space2,key,BASILISK_KEYSIZE); memcpy(space2,key,BASILISK_KEYSIZE);
if ( data != 0 && datalen != 0 ) if ( data != 0 && datalen != 0 )
memcpy(&space2[BASILISK_KEYSIZE],data,datalen); memcpy(&space2[BASILISK_KEYSIZE],data,datalen);
dex_reqsend(myinfo,"DEX",space2,datalen+BASILISK_KEYSIZE,1); dex_reqsend(myinfo,"DEX",space2,datalen+BASILISK_KEYSIZE,1,"");
} else printf("sendmessage space too small error for %d\n",datalen); } else printf("sendmessage space too small error for %d\n",datalen);
free(space); free(space);
free(space2); free(space2);

4
basilisk/basilisk_bitcoin.c

@ -550,7 +550,7 @@ char *iguana_utxoduplicates(struct supernet_info *myinfo,struct iguana_info *coi
if ( signedtxidp != 0 ) if ( signedtxidp != 0 )
memset(signedtxidp,0,sizeof(*signedtxidp)); memset(signedtxidp,0,sizeof(*signedtxidp));
bitcoin_address(changeaddr,coin->chain->pubtype,myinfo->persistent_pubkey33,33); bitcoin_address(changeaddr,coin->chain->pubtype,myinfo->persistent_pubkey33,33);
if ( (txobj= bitcoin_txcreate(coin->chain->isPoS,0,1,0)) != 0 ) if ( (txobj= bitcoin_txcreate(coin->symbol,coin->chain->isPoS,0,1,0)) != 0 )
{ {
if ( duplicates <= 0 ) if ( duplicates <= 0 )
duplicates = 1; duplicates = 1;
@ -609,7 +609,7 @@ char *basilisk_bitcoinrawtx(struct supernet_info *myinfo,struct iguana_info *coi
return(clonestr("{\"error\":\"invalid changeaddr or spendscript or addresses\"}")); return(clonestr("{\"error\":\"invalid changeaddr or spendscript or addresses\"}"));
if ( coin != 0 ) if ( coin != 0 )
{ {
if ( (txobj= bitcoin_txcreate(coin->chain->isPoS,locktime,locktime==0?coin->chain->normal_txversion:coin->chain->locktime_txversion,juint(valsobj,"timestamp"))) != 0 ) if ( (txobj= bitcoin_txcreate(coin->symbol,coin->chain->isPoS,locktime,locktime==0?coin->chain->normal_txversion:coin->chain->locktime_txversion,juint(valsobj,"timestamp"))) != 0 )
{ {
spendlen = (int32_t)strlen(spendscriptstr) >> 1; spendlen = (int32_t)strlen(spendscriptstr) >> 1;
decode_hex(buf,spendlen,spendscriptstr); decode_hex(buf,spendlen,spendscriptstr);

2
basilisk/basilisk_swap.c

@ -325,7 +325,7 @@ int32_t basilisk_rawtx_sign(struct supernet_info *myinfo,int32_t height,struct b
V[0].ignore_cltverr = ignore_cltverr; V[0].ignore_cltverr = ignore_cltverr;
if ( dest->I.redeemlen != 0 ) if ( dest->I.redeemlen != 0 )
memcpy(V[0].p2shscript,dest->redeemscript,dest->I.redeemlen), V[0].p2shlen = dest->I.redeemlen; memcpy(V[0].p2shscript,dest->redeemscript,dest->I.redeemlen), V[0].p2shlen = dest->I.redeemlen;
txobj = bitcoin_txcreate(rawtx->coin->chain->isPoS,locktime,userdata == 0 ? 1 : 1,timestamp);//rawtx->coin->chain->locktime_txversion); txobj = bitcoin_txcreate(rawtx->coin->symbol,rawtx->coin->chain->isPoS,locktime,userdata == 0 ? 1 : 1,timestamp);//rawtx->coin->chain->locktime_txversion);
vins = cJSON_CreateArray(); vins = cJSON_CreateArray();
item = cJSON_CreateObject(); item = cJSON_CreateObject();
if ( userdata != 0 && userdatalen > 0 ) if ( userdata != 0 && userdatalen > 0 )

2
gecko/gecko_miner.c

@ -302,7 +302,7 @@ cJSON *gecko_paymentsobj(struct supernet_info *myinfo,cJSON *txjson,cJSON *valso
if ( (txversion= juint(valsobj,"txversion")) == 0 ) if ( (txversion= juint(valsobj,"txversion")) == 0 )
txversion = (locktime == 0) ? IGUANA_NORMAL_TXVERSION : IGUANA_LOCKTIME_TXVERSION; txversion = (locktime == 0) ? IGUANA_NORMAL_TXVERSION : IGUANA_LOCKTIME_TXVERSION;
if ( txjson == 0 ) if ( txjson == 0 )
txjson = bitcoin_txcreate(1,locktime,txversion,juint(valsobj,"timestamp")); txjson = bitcoin_txcreate("gecko",1,locktime,txversion,juint(valsobj,"timestamp"));
if ( (array= jarray(&n,valsobj,"payments")) != 0 && n > 0 ) if ( (array= jarray(&n,valsobj,"payments")) != 0 && n > 0 )
{ {
for (i=0; i<n; i++) for (i=0; i<n; i++)

2
iguana/dPoW.h

@ -143,7 +143,7 @@ struct dpow_info
uint64_t dpow_notarybestk(uint64_t refmask,struct dpow_block *bp,int8_t *lastkp); uint64_t dpow_notarybestk(uint64_t refmask,struct dpow_block *bp,int8_t *lastkp);
int32_t dpow_paxpending(uint8_t *hex,uint32_t *paxwdcrcp); int32_t dpow_paxpending(uint8_t *hex,uint32_t *paxwdcrcp);
void dex_updateclient(struct supernet_info *myinfo); void dex_updateclient(struct supernet_info *myinfo);
char *dex_reqsend(struct supernet_info *myinfo,char *handler,uint8_t *data,int32_t datalen,int32_t M); char *dex_reqsend(struct supernet_info *myinfo,char *handler,uint8_t *data,int32_t datalen,int32_t M,char *field);
char *basilisk_respond_addmessage(struct supernet_info *myinfo,uint8_t *key,int32_t keylen,uint8_t *data,int32_t datalen,int32_t sendping,uint32_t duration); char *basilisk_respond_addmessage(struct supernet_info *myinfo,uint8_t *key,int32_t keylen,uint8_t *data,int32_t datalen,int32_t sendping,uint32_t duration);
int32_t dpow_getchaintip(struct supernet_info *myinfo,bits256 *blockhashp,uint32_t *blocktimep,bits256 *txs,uint32_t *numtxp,struct iguana_info *coin); int32_t dpow_getchaintip(struct supernet_info *myinfo,bits256 *blockhashp,uint32_t *blocktimep,bits256 *txs,uint32_t *numtxp,struct iguana_info *coin);
void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen); void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen);

99
iguana/dpow/dpow_network.c

@ -270,13 +270,9 @@ char *dex_response(int32_t *broadcastflagp,struct supernet_info *myinfo,struct d
else if ( dexreq.func == 'H' ) else if ( dexreq.func == 'H' )
{ {
hash2 = dpow_getblockhash(myinfo,coin,dexreq.intarg); hash2 = dpow_getblockhash(myinfo,coin,dexreq.intarg);
printf("getblockhash %d -> (%s)\n",dexreq.intarg,bits256_str(buf,hash2));
bits256_str(buf,hash2); bits256_str(buf,hash2);
if ( (retstr= clonestr(buf)) != 0 && (retjson= cJSON_Parse(retstr)) != 0 ) retstr = clonestr(buf);
{
dpow_randipbits(myinfo,coin,retjson);
free(retstr);
retstr = jprint(retjson,1);
}
} }
else if ( dexreq.func == 'B' ) else if ( dexreq.func == 'B' )
{ {
@ -306,22 +302,11 @@ char *dex_response(int32_t *broadcastflagp,struct supernet_info *myinfo,struct d
{ {
hash2 = dpow_getbestblockhash(myinfo,coin); hash2 = dpow_getbestblockhash(myinfo,coin);
bits256_str(buf,hash2); bits256_str(buf,hash2);
if ( (retstr= clonestr(buf)) != 0 && (retjson= cJSON_Parse(retstr)) != 0 ) retstr = clonestr(buf);
{
dpow_randipbits(myinfo,coin,retjson);
free(retstr);
retstr = jprint(retjson,1);
}
} }
else if ( dexreq.func == 'S' ) else if ( dexreq.func == 'S' )
{ {
retstr = dpow_sendrawtransaction(myinfo,coin,(char *)&dexp->packet[datalen]); retstr = dpow_sendrawtransaction(myinfo,coin,(char *)&dexp->packet[datalen]);
if ( retstr != 0 && (retjson= cJSON_Parse(retstr)) != 0 )
{
dpow_randipbits(myinfo,coin,retjson);
free(retstr);
retstr = jprint(retjson,1);
}
} }
else if ( dexreq.func == '*' ) else if ( dexreq.func == '*' )
{ {
@ -372,15 +357,16 @@ char *dex_response(int32_t *broadcastflagp,struct supernet_info *myinfo,struct d
return(retstr); return(retstr);
} }
char *dex_reqsend(struct supernet_info *myinfo,char *handler,uint8_t *data,int32_t datalen,int32_t M) char *dex_reqsend(struct supernet_info *myinfo,char *handler,uint8_t *data,int32_t datalen,int32_t M,char *field)
{ {
char *retstrs[64]; int32_t i,j,max = myinfo->numdexipbits; char *retstrs[64],*origretstr0 = 0; cJSON *retjson; int32_t err,i,j,max = myinfo->numdexipbits;
memset(retstrs,0,sizeof(retstrs)); memset(retstrs,0,sizeof(retstrs));
for (i=j=0; i<=max; i++) for (i=j=0; i<=max; i++)
{ {
if ( (retstrs[j]= _dex_reqsend(myinfo,handler,data,datalen)) != 0 ) if ( (retstrs[j]= _dex_reqsend(myinfo,handler,data,datalen)) != 0 )
{ {
if ( strncmp(retstrs[j],"{\"error\":\"null return\"}",strlen("{\"error\":\"null return\"}")) != 0 && strncmp(retstrs[j],"[]",strlen("[]")) != 0 ) printf("j.%d of max.%d (%s)\n",j,max,retstrs[j]);
if ( strncmp(retstrs[j],"{\"error\":\"null return\"}",strlen("{\"error\":\"null return\"}")) != 0 && strncmp(retstrs[j],"[]",strlen("[]")) != 0 && strcmp("0",retstrs[j]) != 0 )
{ {
if ( ++j == M ) if ( ++j == M )
break; break;
@ -394,23 +380,58 @@ char *dex_reqsend(struct supernet_info *myinfo,char *handler,uint8_t *data,int32
return(retstrs[0]); return(retstrs[0]);
else else
{ {
for (i=0; i<j; i++) err = 0;
printf("(%s).%d\n",retstrs[i],i); if ( strcmp(field,"*") != 0 )
{
for (i=0; i<j; i++)
{
printf("%s ",retstrs[i]);
if ( (retjson= cJSON_Parse(retstrs[i])) != 0 )
{
if ( i == 0 )
origretstr0 = retstrs[0];
else free(retstrs[i]);
retstrs[i] = jprint(jobj(retjson,field),0);
free_json(retjson);
printf("(%s).%d\n",retstrs[i],i);
} else err++;
}
}
if ( err == 0 )
{
for (i=1; i<j; i++)
if ( strcmp(retstrs[0],retstrs[i]) != 0 )
{
err = 1;
break;
}
}
if ( err != 0 )
{
for (i=0; i<j; i++)
free(retstrs[i]);
retstrs[0] = clonestr("{\"error\":\"couldnt get consensus\"}");
}
else
{
free(retstrs[0]);
retstrs[0] = origretstr0;
}
} }
return(retstrs[0]); return(retstrs[0]);
} }
char *_dex_sendrequest(struct supernet_info *myinfo,struct dex_request *dexreq,int32_t M) char *_dex_sendrequest(struct supernet_info *myinfo,struct dex_request *dexreq,int32_t M,char *field)
{ {
uint8_t packet[sizeof(*dexreq)]; int32_t datalen; uint8_t packet[sizeof(*dexreq)]; int32_t datalen;
if ( iguana_isnotarychain(dexreq->name) >= 0 ) if ( iguana_isnotarychain(dexreq->name) >= 0 )
{ {
datalen = dex_rwrequest(1,packet,dexreq); datalen = dex_rwrequest(1,packet,dexreq);
return(dex_reqsend(myinfo,"request",packet,datalen,M)); return(dex_reqsend(myinfo,"request",packet,datalen,M,field));
} else return(clonestr("{\"error\":\"not notarychain\"}")); } else return(clonestr("{\"error\":\"not notarychain\"}"));
} }
char *_dex_sendrequeststr(struct supernet_info *myinfo,struct dex_request *dexreq,char *str,int32_t M) char *_dex_sendrequeststr(struct supernet_info *myinfo,struct dex_request *dexreq,char *str,int32_t M,char *field)
{ {
uint8_t *packet; int32_t datalen,slen; char *retstr; uint8_t *packet; int32_t datalen,slen; char *retstr;
if ( iguana_isnotarychain(dexreq->name) >= 0 ) if ( iguana_isnotarychain(dexreq->name) >= 0 )
@ -420,7 +441,7 @@ char *_dex_sendrequeststr(struct supernet_info *myinfo,struct dex_request *dexre
datalen = dex_rwrequest(1,packet,dexreq); datalen = dex_rwrequest(1,packet,dexreq);
strcpy((char *)&packet[datalen],str); strcpy((char *)&packet[datalen],str);
datalen += slen; datalen += slen;
retstr = dex_reqsend(myinfo,"request",packet,datalen,M); retstr = dex_reqsend(myinfo,"request",packet,datalen,M,field);
free(packet); free(packet);
return(retstr); return(retstr);
} else return(clonestr("{\"error\":\"not notarychain\"}")); } else return(clonestr("{\"error\":\"not notarychain\"}"));
@ -433,7 +454,7 @@ char *_dex_getrawtransaction(struct supernet_info *myinfo,char *symbol,bits256 t
safecopy(dexreq.name,symbol,sizeof(dexreq.name)); safecopy(dexreq.name,symbol,sizeof(dexreq.name));
dexreq.hash = txid; dexreq.hash = txid;
dexreq.func = 'T'; dexreq.func = 'T';
return(_dex_sendrequest(myinfo,&dexreq,1)); return(_dex_sendrequest(myinfo,&dexreq,1,""));
} }
char *_dex_gettxout(struct supernet_info *myinfo,char *symbol,bits256 txid,int32_t vout) char *_dex_gettxout(struct supernet_info *myinfo,char *symbol,bits256 txid,int32_t vout)
@ -445,7 +466,7 @@ char *_dex_gettxout(struct supernet_info *myinfo,char *symbol,bits256 txid,int32
dexreq.hash = txid; dexreq.hash = txid;
dexreq.shortarg = vout; dexreq.shortarg = vout;
dexreq.func = 'O'; dexreq.func = 'O';
return(_dex_sendrequest(myinfo,&dexreq,3)); return(_dex_sendrequest(myinfo,&dexreq,3,"value"));
} }
char *_dex_getinfo(struct supernet_info *myinfo,char *symbol) char *_dex_getinfo(struct supernet_info *myinfo,char *symbol)
@ -454,7 +475,7 @@ char *_dex_getinfo(struct supernet_info *myinfo,char *symbol)
memset(&dexreq,0,sizeof(dexreq)); memset(&dexreq,0,sizeof(dexreq));
safecopy(dexreq.name,symbol,sizeof(dexreq.name)); safecopy(dexreq.name,symbol,sizeof(dexreq.name));
dexreq.func = 'I'; dexreq.func = 'I';
return(_dex_sendrequest(myinfo,&dexreq,1)); return(_dex_sendrequest(myinfo,&dexreq,1,""));
} }
char *_dex_alladdresses(struct supernet_info *myinfo,char *symbol) char *_dex_alladdresses(struct supernet_info *myinfo,char *symbol)
@ -463,7 +484,7 @@ char *_dex_alladdresses(struct supernet_info *myinfo,char *symbol)
memset(&dexreq,0,sizeof(dexreq)); memset(&dexreq,0,sizeof(dexreq));
safecopy(dexreq.name,symbol,sizeof(dexreq.name)); safecopy(dexreq.name,symbol,sizeof(dexreq.name));
dexreq.func = '*'; dexreq.func = '*';
return(_dex_sendrequest(myinfo,&dexreq,1)); return(_dex_sendrequest(myinfo,&dexreq,1,""));
} }
char *_dex_getblock(struct supernet_info *myinfo,char *symbol,bits256 hash2) char *_dex_getblock(struct supernet_info *myinfo,char *symbol,bits256 hash2)
@ -473,7 +494,7 @@ char *_dex_getblock(struct supernet_info *myinfo,char *symbol,bits256 hash2)
safecopy(dexreq.name,symbol,sizeof(dexreq.name)); safecopy(dexreq.name,symbol,sizeof(dexreq.name));
dexreq.hash = hash2; dexreq.hash = hash2;
dexreq.func = 'B'; dexreq.func = 'B';
return(_dex_sendrequest(myinfo,&dexreq,1)); return(_dex_sendrequest(myinfo,&dexreq,1,""));
} }
char *_dex_getblockhash(struct supernet_info *myinfo,char *symbol,int32_t height) char *_dex_getblockhash(struct supernet_info *myinfo,char *symbol,int32_t height)
@ -483,7 +504,7 @@ char *_dex_getblockhash(struct supernet_info *myinfo,char *symbol,int32_t height
safecopy(dexreq.name,symbol,sizeof(dexreq.name)); safecopy(dexreq.name,symbol,sizeof(dexreq.name));
dexreq.intarg = height; dexreq.intarg = height;
dexreq.func = 'H'; dexreq.func = 'H';
return(_dex_sendrequest(myinfo,&dexreq,1)); return(_dex_sendrequest(myinfo,&dexreq,3,"*"));
} }
char *_dex_getbestblockhash(struct supernet_info *myinfo,char *symbol) char *_dex_getbestblockhash(struct supernet_info *myinfo,char *symbol)
@ -492,7 +513,7 @@ char *_dex_getbestblockhash(struct supernet_info *myinfo,char *symbol)
memset(&dexreq,0,sizeof(dexreq)); memset(&dexreq,0,sizeof(dexreq));
safecopy(dexreq.name,symbol,sizeof(dexreq.name)); safecopy(dexreq.name,symbol,sizeof(dexreq.name));
dexreq.func = 'P'; dexreq.func = 'P';
return(_dex_sendrequest(myinfo,&dexreq,3)); return(_dex_sendrequest(myinfo,&dexreq,1,""));
} }
char *_dex_sendrawtransaction(struct supernet_info *myinfo,char *symbol,char *signedtx) char *_dex_sendrawtransaction(struct supernet_info *myinfo,char *symbol,char *signedtx)
@ -501,7 +522,7 @@ char *_dex_sendrawtransaction(struct supernet_info *myinfo,char *symbol,char *si
memset(&dexreq,0,sizeof(dexreq)); memset(&dexreq,0,sizeof(dexreq));
safecopy(dexreq.name,symbol,sizeof(dexreq.name)); safecopy(dexreq.name,symbol,sizeof(dexreq.name));
dexreq.func = 'S'; dexreq.func = 'S';
return(_dex_sendrequeststr(myinfo,&dexreq,signedtx,3)); return(_dex_sendrequeststr(myinfo,&dexreq,signedtx,3,"*"));
} }
char *_dex_importaddress(struct supernet_info *myinfo,char *symbol,char *address) char *_dex_importaddress(struct supernet_info *myinfo,char *symbol,char *address)
@ -510,7 +531,7 @@ char *_dex_importaddress(struct supernet_info *myinfo,char *symbol,char *address
memset(&dexreq,0,sizeof(dexreq)); memset(&dexreq,0,sizeof(dexreq));
safecopy(dexreq.name,symbol,sizeof(dexreq.name)); safecopy(dexreq.name,symbol,sizeof(dexreq.name));
dexreq.func = 'A'; dexreq.func = 'A';
return(_dex_sendrequeststr(myinfo,&dexreq,address,1)); return(_dex_sendrequeststr(myinfo,&dexreq,address,1,""));
} }
char *_dex_validateaddress(struct supernet_info *myinfo,char *symbol,char *address) char *_dex_validateaddress(struct supernet_info *myinfo,char *symbol,char *address)
@ -519,7 +540,7 @@ char *_dex_validateaddress(struct supernet_info *myinfo,char *symbol,char *addre
memset(&dexreq,0,sizeof(dexreq)); memset(&dexreq,0,sizeof(dexreq));
safecopy(dexreq.name,symbol,sizeof(dexreq.name)); safecopy(dexreq.name,symbol,sizeof(dexreq.name));
dexreq.func = 'V'; dexreq.func = 'V';
return(_dex_sendrequeststr(myinfo,&dexreq,address,1)); return(_dex_sendrequeststr(myinfo,&dexreq,address,1,""));
} }
char *_dex_listunspent(struct supernet_info *myinfo,char *symbol,char *address) char *_dex_listunspent(struct supernet_info *myinfo,char *symbol,char *address)
@ -528,7 +549,7 @@ char *_dex_listunspent(struct supernet_info *myinfo,char *symbol,char *address)
memset(&dexreq,0,sizeof(dexreq)); memset(&dexreq,0,sizeof(dexreq));
safecopy(dexreq.name,symbol,sizeof(dexreq.name)); safecopy(dexreq.name,symbol,sizeof(dexreq.name));
dexreq.func = 'U'; dexreq.func = 'U';
return(_dex_sendrequeststr(myinfo,&dexreq,address,1)); return(_dex_sendrequeststr(myinfo,&dexreq,address,1,""));
} }
char *_dex_listtransactions(struct supernet_info *myinfo,char *symbol,char *address,int32_t count,int32_t skip) char *_dex_listtransactions(struct supernet_info *myinfo,char *symbol,char *address,int32_t count,int32_t skip)
@ -539,7 +560,7 @@ char *_dex_listtransactions(struct supernet_info *myinfo,char *symbol,char *addr
dexreq.intarg = skip; dexreq.intarg = skip;
dexreq.shortarg = count; dexreq.shortarg = count;
dexreq.func = 'L'; dexreq.func = 'L';
return(_dex_sendrequeststr(myinfo,&dexreq,address,1)); return(_dex_sendrequeststr(myinfo,&dexreq,address,1,""));
} }
int32_t dex_crc32find(struct supernet_info *myinfo,uint32_t crc32) int32_t dex_crc32find(struct supernet_info *myinfo,uint32_t crc32)

2
iguana/iguana_notary.c

@ -381,7 +381,7 @@ TWO_STRINGS(dex,send,hex,handler)
decode_hex(data,datalen,hex); decode_hex(data,datalen,hex);
if ( handler == 0 || handler[0] == 0 ) if ( handler == 0 || handler[0] == 0 )
handler = "DEX"; handler = "DEX";
if ( (retstr= dex_reqsend(myinfo,handler,data,datalen,1)) == 0 ) if ( (retstr= dex_reqsend(myinfo,handler,data,datalen,1,"")) == 0 )
return(clonestr("{\"result\":\"success\"}")); return(clonestr("{\"result\":\"success\"}"));
else return(retstr); else return(retstr);
} else return(clonestr("{\"error\":\"dex send: invalid hex\"}")); } else return(clonestr("{\"error\":\"dex send: invalid hex\"}"));

2
iguana/iguana_payments.c

@ -1236,7 +1236,7 @@ ARRAY_OBJ_INT(bitcoinrpc,createrawtransaction,vins,vouts,locktime)
bits256 txid; int32_t offset,spendlen=0,n; uint8_t addrtype,rmd160[20],spendscript[IGUANA_MAXSCRIPTSIZE]; uint64_t satoshis; char *hexstr,*field,*txstr; cJSON *txobj,*item,*obj,*retjson = cJSON_CreateObject(); bits256 txid; int32_t offset,spendlen=0,n; uint8_t addrtype,rmd160[20],spendscript[IGUANA_MAXSCRIPTSIZE]; uint64_t satoshis; char *hexstr,*field,*txstr; cJSON *txobj,*item,*obj,*retjson = cJSON_CreateObject();
if ( remoteaddr != 0 ) if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}")); return(clonestr("{\"error\":\"no remote\"}"));
if ( coin != 0 && (txobj= bitcoin_txcreate(coin->chain->isPoS,locktime,1,0)) != 0 ) if ( coin != 0 && (txobj= bitcoin_txcreate(coin->symbol,coin->chain->isPoS,locktime,1,0)) != 0 )
{ {
iguana_createvins(myinfo,coin,txobj,vins); iguana_createvins(myinfo,coin,txobj,vins);
if ( (n= cJSON_GetArraySize(vouts)) > 0 ) if ( (n= cJSON_GetArraySize(vouts)) > 0 )

6
iguana/iguana_sign.c

@ -1245,10 +1245,12 @@ cJSON *bitcoin_txinput(struct iguana_info *coin,cJSON *txobj,bits256 txid,int32_
return(txobj); return(txobj);
} }
cJSON *bitcoin_txcreate(int32_t isPoS,int64_t locktime,uint32_t txversion,uint32_t timestamp) cJSON *bitcoin_txcreate(char *symbol,int32_t isPoS,int64_t locktime,uint32_t txversion,uint32_t timestamp)
{ {
cJSON *json = cJSON_CreateObject(); cJSON *json = cJSON_CreateObject();
jaddnum(json,"version",txversion); jaddnum(json,"version",txversion);
if ( locktime == 0 && strcmp(symbol,"KMD") == 0 )
locktime = (uint32_t)time(NULL);
jaddnum(json,"locktime",locktime); jaddnum(json,"locktime",locktime);
if ( isPoS != 0 ) if ( isPoS != 0 )
jaddnum(json,"timestamp",timestamp == 0 ? time(NULL) : timestamp); jaddnum(json,"timestamp",timestamp == 0 ? time(NULL) : timestamp);
@ -1356,7 +1358,7 @@ P2SH_SPENDAPI(iguana,spendmsig,activecoin,vintxid,vinvout,destaddress,destamount
if ( M > N || N > 3 ) if ( M > N || N > 3 )
return(clonestr("{\"error\":\"illegal M or N\"}")); return(clonestr("{\"error\":\"illegal M or N\"}"));
memset(&V,0,sizeof(V)); memset(&V,0,sizeof(V));
txobj = bitcoin_txcreate(active->chain->isPoS,0,coin->chain->normal_txversion,0); txobj = bitcoin_txcreate(active->symbol,active->chain->isPoS,0,coin->chain->normal_txversion,0);
if ( destaddress[0] != 0 && destamount > 0. ) if ( destaddress[0] != 0 && destamount > 0. )
bitcoin_txaddspend(active,txobj,destaddress,destamount * SATOSHIDEN); bitcoin_txaddspend(active,txobj,destaddress,destamount * SATOSHIDEN);
if ( destaddress2[0] != 0 && destamount2 > 0. ) if ( destaddress2[0] != 0 && destamount2 > 0. )

2
iguana/tests/dexgetH

@ -1,2 +1,2 @@
#!/bin/bash #!/bin/bash
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"getblockhash\",\"height\":400000,\"symbol\":\"BTC\"}" curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"getblockhash\",\"height\":100000,\"symbol\":\"KMD\"}"

2
iguana/tests/dexlistunspent

@ -1,2 +1,2 @@
#!/bin/bash #!/bin/bash
curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"listunspent\",\"address\":\"1Hgzt5xsnbfc8UTWqWKSTLRm5bEYHYBoCE\",\"symbol\":\"BTC\"}" curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"listunspent\",\"address\":\"RRyBxbrAPRUBCUpiJgJZYrkxqrh8x5ta9Z\",\"symbol\":\"KMD\"}"

2
includes/iguana_funcs.h

@ -308,7 +308,7 @@ cJSON *iguana_signtx(struct supernet_info *myinfo,struct iguana_info *coin,bits2
void iguana_addscript(struct iguana_info *coin,cJSON *dest,uint8_t *script,int32_t scriptlen,char *fieldname); void iguana_addscript(struct iguana_info *coin,cJSON *dest,uint8_t *script,int32_t scriptlen,char *fieldname);
bits256 iguana_genesis(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_chain *chain); bits256 iguana_genesis(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_chain *chain);
cJSON *bitcoin_txcreate(int32_t isPoS,int64_t locktime,uint32_t txversion,uint32_t timestamp); cJSON *bitcoin_txcreate(char *symbol,int32_t isPoS,int64_t locktime,uint32_t txversion,uint32_t timestamp);
cJSON *bitcoin_txoutput(cJSON *txobj,uint8_t *paymentscript,int32_t len,uint64_t satoshis); cJSON *bitcoin_txoutput(cJSON *txobj,uint8_t *paymentscript,int32_t len,uint64_t satoshis);
cJSON *bitcoin_txinput(struct iguana_info *coin,cJSON *txobj,bits256 txid,int32_t vout,uint32_t sequenceid,uint8_t *spendscript,int32_t spendlen,uint8_t *redeemscript,int32_t p2shlen,uint8_t *pubkeys[],int32_t numpubkeys,uint8_t *sigscript,int32_t siglen); cJSON *bitcoin_txinput(struct iguana_info *coin,cJSON *txobj,bits256 txid,int32_t vout,uint32_t sequenceid,uint8_t *spendscript,int32_t spendlen,uint8_t *redeemscript,int32_t p2shlen,uint8_t *pubkeys[],int32_t numpubkeys,uint8_t *sigscript,int32_t siglen);

Loading…
Cancel
Save