Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
c1be09812b
  1. 20
      iguana/exchanges/bitcoin.c
  2. 10
      iguana/swaps/iguana_BTCswap.c

20
iguana/exchanges/bitcoin.c

@ -823,7 +823,7 @@ int32_t iguana_scriptgen(struct iguana_info *coin,int32_t *Mp,int32_t *nump,char
init_hexbytes_noT(pubkeystr,(uint8_t *)vp->signers[0].pubkey,plen);
sprintf(asmstr,"OP_DUP %s OP_CHECKSIG // %s",pubkeystr,coinaddr);
scriptlen = bitcoin_pubkeyspend(script,0,(uint8_t *)vp->signers[0].pubkey);
printf("[%02x] scriptlen.%d (%s)\n",vp->signers[0].pubkey[0],scriptlen,asmstr);
//printf("[%02x] scriptlen.%d (%s)\n",vp->signers[0].pubkey[0],scriptlen,asmstr);
break;
case IGUANA_SCRIPT_76A988AC:
sprintf(asmstr,"OP_DUP OP_HASH160 %s OP_EQUALVERIFY OP_CHECKSIG // %s",rmd160str,coinaddr);
@ -1233,7 +1233,7 @@ int32_t iguana_rwmsgtx(struct iguana_info *coin,int32_t rwflag,cJSON *json,uint8
if ( coin->chain->hastimestamp != 0 )
{
len += iguana_rwnum(rwflag,&serialized[len],sizeof(msg->timestamp),&msg->timestamp);
char str[65]; printf("timestamp.%08x %u %s\n",msg->timestamp,msg->timestamp,utc_str(str,msg->timestamp));
//char str[65]; printf("timestamp.%08x %u %s\n",msg->timestamp,msg->timestamp,utc_str(str,msg->timestamp));
if ( json != 0 )
jaddnum(json,"timestamp",msg->timestamp);
}
@ -1499,7 +1499,7 @@ int32_t bitcoin_verifyvins(struct iguana_info *coin,bits256 *signedtxidp,char **
if ( n2 > 0 )
{
n2 += iguana_rwnum(1,&serialized[n2],sizeof(hashtype),&hashtype);
printf("hashtype.%d [%02x]\n",hashtype,sig[siglen-1]);
//printf("hashtype.%d [%02x]\n",hashtype,sig[siglen-1]);
revsigtxid = bits256_doublesha256(txidstr,serialized,n2);
for (i=0; i<sizeof(revsigtxid); i++)
sigtxid.bytes[31-i] = revsigtxid.bytes[i];
@ -1511,9 +1511,9 @@ int32_t bitcoin_verifyvins(struct iguana_info *coin,bits256 *signedtxidp,char **
vp->signers[j].siglen = siglen;
msgtx->vins[vini].sigscript = calloc(1,siglen*2+256); // fix this memleak!
msgtx->vins[vini].scriptlen = bitcoin_scriptsig(coin,msgtx->vins[vini].sigscript,0,(const struct vin_info *)vp,msgtx);
for (i=0; i<siglen; i++)
printf("%02x",sig[i]);
printf(" SIGNEDTX.[%02x] plen.%d siglen.%d\n",sig[siglen-1],plen,siglen);
//for (i=0; i<siglen; i++)
// printf("%02x",sig[i]);
//printf(" SIGNEDTX.[%02x] plen.%d siglen.%d\n",sig[siglen-1],plen,siglen);
}
if ( bitcoin_verify(sig,siglen,sigtxid.bytes,sizeof(sigtxid),0,vp->signers[j].pubkey,bitcoin_pubkeylen(vp->signers[j].pubkey)) < 0 )
{
@ -1528,7 +1528,7 @@ int32_t bitcoin_verifyvins(struct iguana_info *coin,bits256 *signedtxidp,char **
cJSON *txobj = cJSON_CreateObject();
*signedtx = iguana_rawtxbytes(coin,txobj,msgtx);
*signedtxidp = msgtx->txid;
printf("SIG.%d VERIFIED %s (%s)\n",vini,*signedtx,jprint(txobj,1));
//printf("SIG.%d VERIFIED %s (%s)\n",vini,*signedtx,jprint(txobj,1));
flag = 1;
break;
}
@ -1636,7 +1636,7 @@ cJSON *bitcoin_addoutput(struct iguana_info *coin,cJSON *txobj,uint8_t *payments
hexstr = malloc(len*2 + 1);
init_hexbytes_noT(hexstr,paymentscript,len);
jaddstr(skey,"hex",hexstr);
printf("addoutput.(%s %s)\n",hexstr,jprint(skey,0));
//printf("addoutput.(%s %s)\n",hexstr,jprint(skey,0));
free(hexstr);
jadd(item,"scriptPubkey",skey);
jaddi(vouts,item);
@ -1656,7 +1656,7 @@ cJSON *bitcoin_addinput(struct iguana_info *coin,cJSON *txobj,bits256 txid,int32
jaddnum(item,"sequence",sequence);
jaddi(vins,item);
jadd(txobj,"vin",vins);
printf("addvin -> (%s)\n",jprint(txobj,0));
//printf("addvin -> (%s)\n",jprint(txobj,0));
return(txobj);
}
@ -1992,7 +1992,7 @@ struct bitcoin_unspent *iguana_unspentsget(struct supernet_info *myinfo,struct i
}
}
}
printf("numunspents.%d -> %d total %.8f\n",*numunspentsp,n,dstr(total));
//printf("numunspents.%d -> %d total %.8f\n",*numunspentsp,n,dstr(total));
*numunspentsp = n;
free_json(utxo);
} else printf("error parsing.(%s)\n",retstr);

10
iguana/swaps/iguana_BTCswap.c

@ -115,7 +115,7 @@ struct bitcoin_statetx *instantdex_feetx(struct supernet_info *myinfo,struct ins
ptr = calloc(1,sizeof(*ptr) + strlen(feetx) + 1);
strcpy(ptr->txbytes,feetx);
ptr->txid = txid;
printf("%s feetx.%s\n",A->offer.myside != 0 ? "BOB" : "ALICE",feetx);
//printf("%s feetx.%s\n",A->offer.myside != 0 ? "BOB" : "ALICE",feetx);
//disp_tx(myinfo,coin,"feetx",feetx);
free(feetx);
}
@ -201,7 +201,7 @@ struct bitcoin_statetx *instantdex_bobtx(struct supernet_info *myinfo,struct igu
ptr = calloc(1,sizeof(*ptr) + strlen(signedtx) + 1);
strcpy(ptr->txbytes,signedtx);
ptr->txid = txid;
printf("bob deposit.%s\n",signedtx);
//printf("bob deposit.%s\n",signedtx);
//disp_tx(myinfo,coin,depositflag != 0 ? "deposit" : "payment",signedtx);
free(signedtx);
} else printf("error signing bobdeposit numinputs.%d\n",spend->numinputs);
@ -512,7 +512,7 @@ void instantdex_swaptxupdate(struct bitcoin_statetx **ptrp,cJSON *argjson,char *
{
if ( *ptrp != 0 )
{
printf("got replacement %s? (%s)\n",txname,str);
//printf("got replacement %s? (%s)\n",txname,str);
free(*ptrp);
}
*ptrp = calloc(1,sizeof(**ptrp) + strlen(str) + 1);
@ -860,9 +860,11 @@ struct instantdex_stateinfo *BTC_initFSM(int32_t *n)
// to reach sentprivs, all paths must have sent/recv deck and Chose and verified cut and choose
s = instantdex_statecreate(s,n,"BOB_sentprivs",BTC_waitprivsfunc,0,"BTC_cleanup",0,0);
instantdex_addevent(s,*n,"BOB_sentprivs","BTCprivs","poll","BOB_waitfee");
instantdex_addevent(s,*n,"BOB_sentprivs","poll","poll","BOB_sentprivs");
s = instantdex_statecreate(s,n,"ALICE_sentprivs",BTC_waitprivsfunc,0,"BTC_cleanup",0,0);
instantdex_addevent(s,*n,"ALICE_sentprivs","BTCprivs","poll","Alice_waitfee");
instantdex_addevent(s,*n,"ALICE_sentprivs","poll","poll","ALICE_sentprivs");
// [BLOCKING: fee] Bob waits for fee and sends deposit when it appears
s = instantdex_statecreate(s,n,"BOB_waitfee",BOB_waitfeefunc,0,"BTC_cleanup",0,0);

Loading…
Cancel
Save