jl777 8 years ago
parent
commit
9225a5edca
  1. 56
      iguana/iguana_notary.c

56
iguana/iguana_notary.c

@ -455,7 +455,7 @@ cJSON *dpow_createtx(struct iguana_info *coin,cJSON **vinsp,struct dpow_entry no
int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct dpow_info *dp,struct iguana_info *coin,bits256 *signedtxidp,char *signedtx,uint64_t mask,int32_t lastk,struct dpow_entry notaries[DPOW_MAXRELAYS],int32_t numnotaries,int32_t height,int32_t myind,bits256 hashmsg,bits256 btctxid) int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct dpow_info *dp,struct iguana_info *coin,bits256 *signedtxidp,char *signedtx,uint64_t mask,int32_t lastk,struct dpow_entry notaries[DPOW_MAXRELAYS],int32_t numnotaries,int32_t height,int32_t myind,bits256 hashmsg,bits256 btctxid)
{ {
int32_t i,j,siglen,m=0,retval=-1; char *rawtx,*rawtx2,*sigstr; cJSON *txobj,*sigobj,*txobj2,*vins,*item,*vin; uint8_t data[128]; bits256 txid,srchash,desthash; uint32_t channel; int32_t i,j,siglen,m=0,retval=-1; char *rawtx,*jsonstr,*rawtx2,*sigstr; cJSON *txobj,*signobj,*sigobj,*txobj2,*vins,*item,*vin; uint8_t data[128]; bits256 txid,srchash,desthash; uint32_t channel;
channel = 's' | ('i' << 8) | ('g' << 16) | ('s' << 24); channel = 's' | ('i' << 8) | ('g' << 16) | ('s' << 24);
for (j=0; j<sizeof(srchash); j++) for (j=0; j<sizeof(srchash); j++)
srchash.bytes[j] = myinfo->DPOW.minerkey33[j+1]; srchash.bytes[j] = myinfo->DPOW.minerkey33[j+1];
@ -463,44 +463,44 @@ int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct dpow_info *dp,struc
{ {
if ( (rawtx= bitcoin_json2hex(myinfo,coin,&txid,txobj,0)) != 0 ) if ( (rawtx= bitcoin_json2hex(myinfo,coin,&txid,txobj,0)) != 0 )
{ {
if ( (signedtx= dpow_signrawtransaction(myinfo,coin,rawtx,vins)) != 0 ) if ( (jsonstr= dpow_signrawtransaction(myinfo,coin,rawtx,vins)) != 0 )
{ {
if ( (rawtx2= dpow_decoderawtransaction(myinfo,coin,signedtx)) != 0 ) if ( (signobj= cJSON_Parse(jsonstr)) != 0 )
{ {
if ( (txobj2= cJSON_Parse(rawtx2)) != 0 ) if ( (signedtx= jstr(signobj,"result")) != 0 && (rawtx2= dpow_decoderawtransaction(myinfo,coin,signedtx)) != 0 )
{ {
printf("txobj2.(%s)\n",jprint(txobj2,0)); if ( (txobj2= cJSON_Parse(rawtx2)) != 0 )
if ( (vin= jarray(&m,txobj2,"vin")) != 0 && myind < m )
{ {
item = jitem(vin,myind); printf("txobj2.(%s)\n",jprint(txobj2,0));
printf("myvin.(%s)\n",jprint(item,0)); if ( (vin= jarray(&m,txobj2,"vin")) != 0 && myind < m )
if ( (sigobj= jobj(item,"scriptSig")) != 0 && (sigstr= jstr(sigobj,"hex")) != 0 )
{ {
siglen = (int32_t)strlen(sigstr) >> 1; item = jitem(vin,myind);
data[0] = myind; printf("myvin.(%s)\n",jprint(item,0));
data[1] = lastk; if ( (sigobj= jobj(item,"scriptSig")) != 0 && (sigstr= jstr(sigobj,"hex")) != 0 )
iguana_rwnum(1,&data[2],sizeof(mask),(uint8_t *)&mask);
data[10] = siglen;
decode_hex(data+11,siglen,sigstr);
for (i=0; i<numnotaries; i++)
{ {
for (j=0; j<sizeof(desthash); j++) siglen = (int32_t)strlen(sigstr) >> 1;
desthash.bytes[j] = notaries[i].pubkey[j+1]; data[0] = myind;
printf("send to notary.%d\n",i); data[1] = lastk;
basilisk_channelsend(myinfo,srchash,desthash,channel,height,data,siglen+11,600); iguana_rwnum(1,&data[2],sizeof(mask),(uint8_t *)&mask);
data[10] = siglen;
decode_hex(data+11,siglen,sigstr);
for (i=0; i<numnotaries; i++)
{
for (j=0; j<sizeof(desthash); j++)
desthash.bytes[j] = notaries[i].pubkey[j+1];
printf("send to notary.%d\n",i);
basilisk_channelsend(myinfo,srchash,desthash,channel,height,data,siglen+11,600);
}
retval = 0;
} }
retval = 0;
} }
free_json(txobj2);
} }
free_json(txobj2); free(rawtx2);
} }
free(rawtx2); free_json(signobj);
} }
/*memset(&msgtx,0,sizeof(msgtx)); free(jsonstr);
if ( (txobj2= bitcoin_hex2json(coin,height,&txid,&msgtx,rawtx,extraspace,sizeof(extraspace),serialized,vins,1)) != 0 )
{
}*/
free(signedtx);
} }
free(rawtx); free(rawtx);
} }

Loading…
Cancel
Save