jl777 8 years ago
parent
commit
b2ca7f2e22
  1. 23
      iguana/dpow/dpow_tx.c
  2. 3
      iguana/iguana_sign.c
  3. 2
      iguana/tests/decoderawtransaction

23
iguana/dpow/dpow_tx.c

@ -225,7 +225,7 @@ int32_t dpow_voutstandard(struct dpow_block *bp,uint8_t *serialized,int32_t m,in
bits256 dpow_notarytx(char *signedtx,int32_t *numsigsp,int32_t isPoS,struct dpow_block *bp,int8_t bestk,uint64_t bestmask,int32_t usesigs,int32_t src_or_dest,uint8_t pubkeys[][33],int32_t numratified)
{
uint32_t k,j,m,numsigs,version,sequenceid = 0xffffffff; bits256 zero; int32_t n,siglen,len; uint8_t serialized[32768],*sig; struct dpow_entry *ep; struct dpow_coinentry *cp;
uint32_t k,j,m,numsigs,version,vout,sequenceid = 0xffffffff; bits256 zero; int32_t n,siglen,len; uint8_t serialized[32768],*sig; bits256 txid; struct dpow_entry *ep; struct dpow_coinentry *cp;
signedtx[0] = 0;
*numsigsp = 0;
memset(zero.bytes,0,sizeof(zero));
@ -245,17 +245,17 @@ bits256 dpow_notarytx(char *signedtx,int32_t *numsigsp,int32_t isPoS,struct dpow
{
if ( src_or_dest != 0 )
{
char str[65]; printf("k.%d RATIFY DEST.%s\n",k,bits256_str(str,bp->notaries[k].ratifydestutxo));
len += iguana_rwbignum(1,&serialized[len],sizeof(bp->notaries[k].ratifydestutxo),bp->notaries[k].ratifydestutxo.bytes);
len += iguana_rwnum(1,&serialized[len],sizeof(bp->notaries[k].ratifydestvout),&bp->notaries[k].ratifydestvout);
txid = bp->notaries[k].ratifydestutxo;
vout = bp->notaries[k].ratifydestvout;
}
else
{
len += iguana_rwbignum(1,&serialized[len],sizeof(bp->notaries[k].ratifysrcutxo),bp->notaries[k].ratifysrcutxo.bytes);
len += iguana_rwnum(1,&serialized[len],sizeof(bp->notaries[k].ratifysrcvout),&bp->notaries[k].ratifysrcvout);
txid = bp->notaries[k].ratifysrcutxo;
vout = bp->notaries[k].ratifysrcvout;
}
siglen = bp->notaries[k].ratifysiglens[src_or_dest];
sig = bp->notaries[k].ratifysigs[src_or_dest];
char str[65]; printf("j.%d k.%d m.%d vin.(%s) v%d siglen.%d\n",j,k,m,bits256_str(str,txid),vout,siglen);
}
else
{
@ -266,11 +266,13 @@ bits256 dpow_notarytx(char *signedtx,int32_t *numsigsp,int32_t isPoS,struct dpow
printf("null prevhash k.%d j.%d src_or_dest.%d\n",k,j,src_or_dest);
return(zero);
}
len += iguana_rwbignum(1,&serialized[len],sizeof(cp->prev_hash),cp->prev_hash.bytes);
len += iguana_rwnum(1,&serialized[len],sizeof(cp->prev_vout),&cp->prev_vout);
txid = cp->prev_hash;
vout = cp->prev_vout;
siglen = cp->siglens[bestk];
sig = cp->sigs[bestk];
}
len += iguana_rwbignum(1,&serialized[len],sizeof(txid),txid.bytes);
len += iguana_rwnum(1,&serialized[len],sizeof(vout),&vout);
if ( usesigs != 0 )
{
len += iguana_rwvarint32(1,&serialized[len],(uint32_t *)&siglen);
@ -423,12 +425,11 @@ int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct dpow_info *dp,struc
return(-1);
for (j=0; j<sizeof(srchash); j++)
srchash.bytes[j] = dp->minerkey33[j+1];
printf("signedtxgen src_or_dest.%d (%d %llx) useratified.%d\n",src_or_dest,bestk,(long long)bestmask,useratified);
if ( (vins= dpow_vins(coin,bp,bestk,bestmask,1,src_or_dest,useratified)) != 0 )
{
printf("call notarytx\n");
printf("signedtxgen src_or_dest.%d (%d %llx) useratified.%d\n",src_or_dest,bestk,(long long)bestmask,useratified);
txid = dpow_notarytx(rawtx,&numsigs,coin->chain->isPoS,bp,bestk,bestmask,0,src_or_dest,bp->numratified!=0?bp->ratified_pubkeys:0,useratified);
printf("got notarytx (%s)\n",rawtx);
printf("got notarytx (%s) vins.(%s)\n",rawtx,jprint(vins,0));
if ( bits256_nonz(txid) != 0 && rawtx[0] != 0 ) // send tx to share utxo set
{
if ( useratified != 0 )

3
iguana/iguana_sign.c

@ -22,8 +22,8 @@ int32_t iguana_vinparse(struct iguana_info *coin,int32_t rwflag,uint8_t *seriali
{
int32_t p2shlen,len = 0; uint32_t tmp;
len += iguana_rwbignum(rwflag,&serialized[len],sizeof(msg->prev_hash),msg->prev_hash.bytes);
//char str[65]; printf("prev_hash.(%s)\n",bits256_str(str,msg->prev_hash));
len += iguana_rwnum(rwflag,&serialized[len],sizeof(msg->prev_vout),&msg->prev_vout);
char str[65]; printf("prev_hash.(%s) v%d\n",bits256_str(str,msg->prev_hash),msg->prev_vout);
if ( rwflag == 1 )
{
tmp = msg->scriptlen + msg->userdatalen + msg->p2shlen;
@ -37,6 +37,7 @@ int32_t iguana_vinparse(struct iguana_info *coin,int32_t rwflag,uint8_t *seriali
}
}
len += iguana_rwvarint32(rwflag,&serialized[len],&tmp);
printf("tmp %x %d\n",tmp,tmp);
if ( rwflag == 0 )
{
/*if ( msg->p2shlen != 0 )

2
iguana/tests/decoderawtransaction

@ -1,3 +1,3 @@
#!/bin/bash
#!/bin/bash
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTC\",\"method\":\"decoderawtransaction\",\"params\":[\"01000000020a60dab7f3bffe78198e10c891eaf9f17f9f3d81c7e947460811af732d89c80e0000000000ffffffffee42e9d592854683f92af7fb89df560b0130320cdc6b30583f2b79bf51c898a90000000049483045022100c17c84276605d03c34428920a597e69b77ddfc9e9c605c3a3f65ecc6cd2adbff022024dee05b1c276ee592aa0645b1a70f187d7b2cbf59e9f8f99921f7e054f29c2101ffffffff01a0230000000000002321020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9ac00000000\", 1]}"
curl --url "http://127.0.0.1:7778" --data "{\"coin\":\"BTC\",\"method\":\"decoderawtransaction\",\"params\":[\"0100000008571ec5afd602f294f3eb95adb83da8894399f9de1a72ed85afc913393afbf3f1100000ffffffffd12495518684dbc80de54f3b8b9f631afba2134891a504313a02a4a8dd060064050000ffffffffd4c2c0addec78ca0b57b3e6bea230f81df2a5d577f95a3f435182ae284a673a0040000ffffffffae91226c63f38ec848e834702f5912205a6d7015de8499b9477faea723cf29cd040000ffffffff872bdcedd7fc71f56cb1f4d42d035cd68b6532e77dbf77fb39deabcd873b0c7b020000ffffffff5d6cee4cd0604fb0de4a30199cbee6594137070fa36150460661f4401c5499ff010000ffffffffbcf7cc97c0e064ac8c3839f46bd6c884edb390625c4975f16864376417f1ce5c090000fffffffff116a3ddbcbd8a15b1db14fcad9edb3770085338da8cb78a870fcdf41c1ec7f1080000ffffffff0210270000000000002321020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9ac7017000000000000232103b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828ac00000000\", 1]}"

Loading…
Cancel
Save