|
|
@ -256,7 +256,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,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; |
|
|
|
uint32_t k,m,numsigs,version,vout,crcval,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)); |
|
|
@ -336,6 +336,16 @@ bits256 dpow_notarytx(char *signedtx,int32_t *numsigsp,int32_t isPoS,struct dpow |
|
|
|
len += n; |
|
|
|
init_hexbytes_noT(signedtx,serialized,len); |
|
|
|
//printf("notarytx.(%s) opretlen.%d\n",signedtx,opretlen);
|
|
|
|
if ( usesigs == 0 && bestk >= 0 ) |
|
|
|
{ |
|
|
|
crcval = calc_crc32(0,bp->ratifyrawtx[src_or_dest],bp->rawratifiedlens[src_or_dest]); |
|
|
|
if ( crcval != bp->pendingcrcs[src_or_dest] ) |
|
|
|
{ |
|
|
|
printf("new crcval.[%d] %x != %x\n",src_or_dest,crcval,bp->pendingcrcs[src_or_dest]); |
|
|
|
bp->pendingcrcs[src_or_dest] = crcval; |
|
|
|
} |
|
|
|
bp->notaries[bp->myind].pendingcrcs[src_or_dest] = bp->pendingcrcs[src_or_dest]; |
|
|
|
} |
|
|
|
*numsigsp = numsigs; |
|
|
|
return(bits256_doublesha256(0,serialized,len)); |
|
|
|
} |
|
|
@ -486,7 +496,7 @@ void dpow_rawtxsign(struct supernet_info *myinfo,struct dpow_info *dp,struct igu |
|
|
|
|
|
|
|
int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct dpow_info *dp,struct iguana_info *coin,struct dpow_block *bp,int8_t bestk,uint64_t bestmask,int32_t myind,uint32_t deprec,int32_t src_or_dest,int32_t useratified) |
|
|
|
{ |
|
|
|
int32_t j,m,numsigs,len,siglen,retval=-1; uint32_t crcval; char rawtx[32768],*jsonstr,*rawtx2,*signedtx,*sigstr; cJSON *item,*sobj,*vins,*vin,*txobj2,*signobj; bits256 txid,srchash,zero; struct dpow_entry *ep; |
|
|
|
int32_t j,m,numsigs,len,siglen,retval=-1; char rawtx[32768],*jsonstr,*rawtx2,*signedtx,*sigstr; cJSON *item,*sobj,*vins,*vin,*txobj2,*signobj; bits256 txid,srchash,zero; struct dpow_entry *ep; |
|
|
|
ep = &bp->notaries[myind]; |
|
|
|
memset(&zero,0,sizeof(zero)); |
|
|
|
if ( bestk < 0 ) |
|
|
@ -504,14 +514,7 @@ int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct dpow_info *dp,struc |
|
|
|
len = (int32_t)strlen(rawtx) >> 1; |
|
|
|
if ( len <= sizeof(bp->ratifyrawtx[0]) ) |
|
|
|
{ |
|
|
|
decode_hex(bp->ratifyrawtx[src_or_dest],len,rawtx), bp->rawratifiedlens[src_or_dest] = len; |
|
|
|
crcval = calc_crc32(0,bp->ratifyrawtx[src_or_dest],bp->rawratifiedlens[src_or_dest]); |
|
|
|
if ( crcval != bp->pendingcrcs[src_or_dest] ) |
|
|
|
{ |
|
|
|
printf("new crcval.[%d] %x != %x\n",src_or_dest,crcval,bp->pendingcrcs[src_or_dest]); |
|
|
|
bp->pendingcrcs[src_or_dest] = crcval; |
|
|
|
} |
|
|
|
bp->notaries[bp->myind].pendingcrcs[src_or_dest] = bp->pendingcrcs[src_or_dest]; |
|
|
|
decode_hex(bp->ratifyrawtx[src_or_dest],len,rawtx),bp->rawratifiedlens[src_or_dest] = len; |
|
|
|
} |
|
|
|
if ( (jsonstr= dpow_signrawtransaction(myinfo,coin,rawtx,vins)) != 0 ) |
|
|
|
{ |
|
|
@ -564,6 +567,7 @@ void dpow_sigscheck(struct supernet_info *myinfo,struct dpow_info *dp,struct dpo |
|
|
|
channel = (src_or_dest != 0) ? DPOW_SIGBTCCHANNEL : DPOW_SIGCHANNEL; |
|
|
|
if ( bestk >= 0 && bp->state != 0xffffffff && coin != 0 ) |
|
|
|
{ |
|
|
|
dpow_notarytx(bp->signedtx,&numsigs,coin->chain->isPoS,bp,bestk,bestmask,0,src_or_dest,pubkeys,numratified); // setcrcval
|
|
|
|
signedtxid = dpow_notarytx(bp->signedtx,&numsigs,coin->chain->isPoS,bp,bestk,bestmask,1,src_or_dest,pubkeys,numratified); |
|
|
|
//printf("src_or_dest.%d bestk.%d %llx %s numsigs.%d signedtx.(%s)\n",src_or_dest,bestk,(long long)bestmask,bits256_str(str,signedtxid),numsigs,bp->signedtx);
|
|
|
|
bp->state = 1; |
|
|
|