jl777 8 years ago
parent
commit
3296992574
  1. 72
      iguana/iguana_notary.c
  2. 1
      iguana/notaries.h
  3. 2
      iguana/tests/decoderawtransaction

72
iguana/iguana_notary.c

@ -81,6 +81,26 @@ cJSON *dpow_getblock(struct supernet_info *myinfo,struct iguana_info *coin,bits2
return(json);
}
char *dpow_decoderawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *rawtx)
{
char *retstr;
if ( coin->FULLNODE < 0 )
{
retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"decoderawtransaction",rawtx);
printf("%s decoderawtransaction.(%s)\n",coin->symbol,retstr);
free(rawtx);
}
else if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 )
{
retstr = bitcoinrpc_decoderawtransaction(myinfo,coin,0,0,rawtx,1);
}
else
{
return(0);
}
return(retstr);
}
cJSON *dpow_gettransaction(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid)
{
char buf[128],str[65],*retstr=0,*rawtx=0; cJSON *json = 0;
@ -89,8 +109,7 @@ cJSON *dpow_gettransaction(struct supernet_info *myinfo,struct iguana_info *coin
sprintf(buf,"[\"%s\", 1]",bits256_str(str,txid));
if ( (rawtx= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"getrawtransaction",buf)) != 0 )
{
retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"decoderawtransaction",rawtx);
printf("%s decoderawtransaction.(%s)\n",coin->symbol,retstr);
retstr = dpow_decoderawtransaction(myinfo,coin,rawtx);
free(rawtx);
}
}
@ -433,7 +452,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 i,j,siglen,m=0,retval=-1; char *rawtx,*sigstr; cJSON *txobj,*sigobj,*txobj2,*vins,*item,*vin; uint8_t data[128],extraspace[8192],serialized[16384]; bits256 txid,srchash,desthash; struct iguana_msgtx msgtx; uint32_t channel;
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;
channel = 's' | ('i' << 8) | ('g' << 16) | ('s' << 24);
for (j=0; j<sizeof(srchash); j++)
srchash.bytes[j] = myinfo->DPOW.minerkey33[j+1];
@ -443,34 +462,41 @@ int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct dpow_info *dp,struc
{
if ( (signedtx= dpow_signrawtransaction(myinfo,coin,rawtx,vins)) != 0 )
{
memset(&msgtx,0,sizeof(msgtx));
if ( (txobj2= bitcoin_hex2json(coin,height,&txid,&msgtx,rawtx,extraspace,sizeof(extraspace),serialized,vins,1)) != 0 )
if ( (rawtx2= dpow_decoderawtransaction(myinfo,coin,signedtx)) != 0 )
{
printf("txobj2.(%s)\n",jprint(txobj2,0));
if ( (vin= jarray(&m,txobj2,"vin")) != 0 && myind < m )
if ( (txobj2= cJSON_Parse(rawtx2)) != 0 )
{
item = jitem(vin,myind);
printf("myvin.(%s)\n",jprint(item,0));
if ( (sigobj= jobj(item,"scriptSig")) != 0 && (sigstr= jstr(sigobj,"hex")) != 0 )
printf("txobj2.(%s)\n",jprint(txobj2,0));
if ( (vin= jarray(&m,txobj2,"vin")) != 0 && myind < m )
{
siglen = (int32_t)strlen(sigstr) >> 1;
data[0] = myind;
data[1] = lastk;
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++)
item = jitem(vin,myind);
printf("myvin.(%s)\n",jprint(item,0));
if ( (sigobj= jobj(item,"scriptSig")) != 0 && (sigstr= jstr(sigobj,"hex")) != 0 )
{
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);
siglen = (int32_t)strlen(sigstr) >> 1;
data[0] = myind;
data[1] = lastk;
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);
}
/*memset(&msgtx,0,sizeof(msgtx));
if ( (txobj2= bitcoin_hex2json(coin,height,&txid,&msgtx,rawtx,extraspace,sizeof(extraspace),serialized,vins,1)) != 0 )
{
}*/
free(signedtx);
}
free(rawtx);

1
iguana/notaries.h

@ -34,6 +34,7 @@ char *Notaries[][2] =
{ "traderbill_EU", "03267254424fb00792b9d5cac7124849b70520e125dc0107946c44aecb9aab50fa" },
{ "vanbreuk_EU", "024f3cad7601d2399c131fd070e797d9cd8533868685ddbe515daa53c2e26004c3" },
{ "titomane_EU", "020c909e72415d1abf151b5cbb521c2a1e14a92fb262cdd3237557da804334e1da" },
{ "supernet_AE", "029d93ef78197dc93892d2a30e5a54865f41e0ca3ab7eb8e3dcbc59c8756b6e355" },
{ "Server1","0221876c8259764224dc1a7b70ec956f3fbe9a768cd77f13082cfa60eb6aa2d068"},
{ "Server2","03c7c14e6b1f94585bb571cf3ee5eb9b9ab54bd23d0acb8cf13edad1c515842b66"},
{ "Server3","02d28f8992ff0cd68c5d558cf55ec5b3ada25151519a6cea8cef1bac04c40023b6"},

2
iguana/tests/decoderawtransaction

@ -1 +1 @@
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTCD\",\"method\":\"decoderawtransaction\",\"params\":[\"0100000039f0ef57012da7ff408b643b8c40d69eb1265a0dfc1055a2a1a0635c37abb10a03b44a37a00100000000ffffffff06e8030000000000002321020e0f6fe6e0fcdcac541eb728d6fe538a12adff20412b3c8a7fa892b223a47c2face8030000000000002321020e0f6fe6e0fcdcac541eb728d6fe538a12adff20412b3c8a7fa892b223a47c2face8030000000000002321020e0f6fe6e0fcdcac541eb728d6fe538a12adff20412b3c8a7fa892b223a47c2face8030000000000002321020e0f6fe6e0fcdcac541eb728d6fe538a12adff20412b3c8a7fa892b223a47c2face8030000000000002321020e0f6fe6e0fcdcac541eb728d6fe538a12adff20412b3c8a7fa892b223a47c2fac188e2903000000001976a914b7128d2ee837cf03e30a2c0e3e0181f7b9669bb688ac00000000\", 1]}"
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTC\",\"method\":\"decoderawtransaction\",\"params\":[\"01000000020a60dab7f3bffe78198e10c891eaf9f17f9f3d81c7e947460811af732d89c80e0000000000ffffffffee42e9d592854683f92af7fb89df560b0130320cdc6b30583f2b79bf51c898a90000000049483045022100c17c84276605d03c34428920a597e69b77ddfc9e9c605c3a3f65ecc6cd2adbff022024dee05b1c276ee592aa0645b1a70f187d7b2cbf59e9f8f99921f7e054f29c2101ffffffff01a0230000000000002321020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9ac00000000\", 1]}"

Loading…
Cancel
Save