Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
58a674b99b
  1. 40
      iguana/exchanges/bitcoin.c
  2. 4
      iguana/iguana_instantdex.c
  3. BIN
      iguana/pnacl/Release/iguana.pexe
  4. 10
      iguana/swaps/iguana_BTCswap.c

40
iguana/exchanges/bitcoin.c

@ -754,7 +754,7 @@ int32_t bitcoin_changescript(struct iguana_info *coin,uint8_t *changescript,int3
return(-1);
}
int32_t bitcoin_scriptsig(uint8_t *script,int32_t n,const struct vin_info *vp)
int32_t bitcoin_scriptsig(struct iguana_info *coin,uint8_t *script,int32_t n,const struct vin_info *vp,struct iguana_msgtx *msgtx)
{
int32_t i,siglen;
if ( vp->N > 1 )
@ -768,7 +768,10 @@ int32_t bitcoin_scriptsig(uint8_t *script,int32_t n,const struct vin_info *vp)
}
}
if ( vp->type == IGUANA_SCRIPT_P2SH )
{
printf("add p2sh script to sig\n");
n = bitcoin_p2shscript(script,n,vp->p2shscript,vp->p2shlen);
}
return(n);
}
@ -1173,9 +1176,18 @@ int32_t iguana_vinparse(struct iguana_info *coin,int32_t rwflag,uint8_t *seriali
len += iguana_rwnum(rwflag,&serialized[len],sizeof(msg->prev_vout),&msg->prev_vout);
len += iguana_rwvarint32(rwflag,&serialized[len],&msg->scriptlen);
if ( rwflag == 0 )
{
msg->sigscript = &serialized[len];
else memcpy(&serialized[len],msg->sigscript,msg->scriptlen);
len += msg->scriptlen;
len += msg->scriptlen;
}
else
{
if ( msg->scriptlen > 0 )
{
memcpy(&serialized[len],msg->sigscript,msg->scriptlen);
len += msg->scriptlen;
}
}
len += iguana_rwnum(rwflag,&serialized[len],sizeof(msg->sequence),&msg->sequence);
if ( 0 )
{
@ -1438,8 +1450,6 @@ int32_t bitcoin_verifyvins(struct iguana_info *coin,bits256 *signedtxidp,char **
{
//saveinput = msgtx->vins[vini].sigscript;
vp = &V[vini];
//for (i=0; i<numvins; i++)
// msgtx->vins[i].spendlen = 0;
sig = &msgtx->vins[vini].sigscript[1];
siglen = msgtx->vins[vini].sigscript[0];
vp->vin = msgtx->vins[vini];
@ -1479,7 +1489,6 @@ int32_t bitcoin_verifyvins(struct iguana_info *coin,bits256 *signedtxidp,char **
}
bitcoin_address(coinaddr,coin->chain->pubtype,pubkey,plen);
n2 = iguana_rwmsgtx(coin,1,0,serialized,maxsize,msgtx,&txid,vpnstr);
//msgtx->vins[vini].script = saveinput;
if ( n2 > 0 )
{
n2 += iguana_rwnum(1,&serialized[n2],sizeof(hashtype),&hashtype);
@ -1489,11 +1498,12 @@ int32_t bitcoin_verifyvins(struct iguana_info *coin,bits256 *signedtxidp,char **
sigtxid.bytes[31-i] = revsigtxid.bytes[i];
if ( 1 && bits256_nonz(vp->signers[j].privkey) != 0 )
{
vp->signers[j].siglen = bitcoin_sign(vp->signers[j].sig,sizeof(vp->signers[j].sig),sigtxid.bytes,sizeof(sigtxid),vp->signers[j].privkey);
siglen = bitcoin_sign(vp->signers[j].sig,sizeof(vp->signers[j].sig),sigtxid.bytes,sizeof(sigtxid),vp->signers[j].privkey);
sig = vp->signers[j].sig;
sig[vp->signers[j].siglen++] = hashtype;
siglen = vp->signers[j].siglen;
msgtx->vins[vini].scriptlen = bitcoin_scriptsig(msgtx->vins[vini].sigscript,0,(const struct vin_info *)vp);
sig[siglen++] = hashtype;
vp->signers[j].siglen = siglen;
msgtx->vins[vini].sigscript = calloc(1,siglen);
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);
@ -1502,12 +1512,16 @@ int32_t bitcoin_verifyvins(struct iguana_info *coin,bits256 *signedtxidp,char **
{
init_hexbytes_noT(bigstr,serialized,n2);
printf("(%s) doesnt verify hash2.%s\n",bigstr,bits256_str(str,sigtxid));
*signedtx = iguana_rawtxbytes(coin,0,msgtx);
*signedtxidp = msgtx->txid;
printf("SIG.%d ERROR %s\n",vini,*signedtx);
}
else
{
*signedtx = iguana_rawtxbytes(coin,0,msgtx);
cJSON *txobj = cJSON_CreateObject();
*signedtx = iguana_rawtxbytes(coin,txobj,msgtx);
*signedtxidp = msgtx->txid;
printf("SIG.%d VERIFIED %s\n",vini,*signedtx);
printf("SIG.%d VERIFIED %s (%s)\n",vini,*signedtx,jprint(txobj,1));
flag = 1;
break;
}
@ -1619,7 +1633,7 @@ cJSON *bitcoin_addoutput(struct iguana_info *coin,cJSON *txobj,uint8_t *payments
jadd(item,"scriptPubkey",skey);
jaddi(vouts,item);
jadd(txobj,"vout",vouts);
///printf("addoutput.(%s %s)\n",hexstr,jprint(skey,0));
printf("addoutput.(%s %s)\n",hexstr,jprint(skey,0));
return(txobj);
}

4
iguana/iguana_instantdex.c

@ -923,8 +923,8 @@ char *instantdex_sendoffer(struct supernet_info *myinfo,struct exchange_info *ex
return(clonestr("{\"error\":\"instantdex_BTCswap offer null newjson\"}"));
else if ( (retstr= instantdex_addfeetx(myinfo,newjson,ap,swap,"BOB_sentoffer","ALICE_sentoffer")) == 0 )
{
instantdex_bobtx(myinfo,iguana_coinfind("BTCD"),&swap->deposittxid,swap->otherpubs[0],swap->mypubs[0],swap->privkeys[swap->choosei],ap->offer.expiration-INSTANTDEX_LOCKTIME*2,swap->satoshis[1],1);
instantdex_alicetx(myinfo,iguana_coinfind("BTCD"),swap->altmsigaddr,&swap->altpaymenttxid,swap->pubAm,swap->pubBn,swap->satoshis[0]);
//instantdex_bobtx(myinfo,iguana_coinfind("BTCD"),&swap->deposittxid,swap->otherpubs[0],swap->mypubs[0],swap->privkeys[swap->choosei],ap->offer.expiration-INSTANTDEX_LOCKTIME*2,swap->satoshis[1],1);
//instantdex_alicetx(myinfo,iguana_coinfind("BTCD"),swap->altmsigaddr,&swap->altpaymenttxid,swap->pubAm,swap->pubBn,swap->satoshis[0]);
if ( 0 )
{
int32_t i;

BIN
iguana/pnacl/Release/iguana.pexe

Binary file not shown.

10
iguana/swaps/iguana_BTCswap.c

@ -89,7 +89,7 @@ int32_t instantdex_outputinsurance(struct iguana_info *coin,cJSON *txobj,int64_t
{
uint8_t rmd160[20],script[128]; int32_t n = 0;
decode_hex(rmd160,sizeof(rmd160),(orderid % 10) == 0 ? TIERNOLAN_RMD160 : INSTANTDEX_RMD160);
script[n++] = sizeof(uint64_t);
script[n++] = sizeof(orderid);
n += iguana_rwnum(1,&script[n],sizeof(orderid),&orderid);
script[n++] = SCRIPT_OP_DROP;
n = bitcoin_standardspend(script,n,rmd160);
@ -101,7 +101,7 @@ void disp_tx(struct supernet_info *myinfo,struct iguana_info *coin,char *str,cha
{
cJSON *txobj; bits256 txid;
txobj = bitcoin_hex2json(coin,&txid,0,txbytes);
printf("%s.(%s)\n",str,jprint(txobj,1));
printf("disp_tx (%s) -> %s.(%s)\n",txbytes,str,jprint(txobj,1));
}
char *instantdex_feetx(struct supernet_info *myinfo,bits256 *txidp,struct instantdex_accept *A)
@ -119,7 +119,7 @@ char *instantdex_feetx(struct supernet_info *myinfo,bits256 *txidp,struct instan
if ( feetx != 0 )
{
printf("%s feetx.%s\n",A->offer.myside != 0 ? "BOB" : "ALICE",feetx);
disp_tx(myinfo,coin,"feetx",feetx);
//disp_tx(myinfo,coin,"feetx",feetx);
}
else printf("error signing %s feetx numinputs.%d\n",A->offer.myside != 0 ? "BOB" : "ALICE",spend->numinputs);
free(spend);
@ -183,7 +183,7 @@ char *instantdex_bobtx(struct supernet_info *myinfo,struct iguana_info *coin,bit
if ( signedtx != 0 )
{
printf("bob deposit.%s\n",signedtx);
disp_tx(myinfo,coin,depositflag != 0 ? "deposit" : "payment",signedtx);
//disp_tx(myinfo,coin,depositflag != 0 ? "deposit" : "payment",signedtx);
} else printf("error signing bobdeposit numinputs.%d\n",spend->numinputs);
free(spend);
}
@ -279,7 +279,7 @@ char *instantdex_alicetx(struct supernet_info *myinfo,struct iguana_info *altcoi
if ( signedtx != 0 )
{
printf("alice payment.%s\n",signedtx);
disp_tx(myinfo,altcoin,"altpayment",signedtx);
//disp_tx(myinfo,altcoin,"altpayment",signedtx);
}
else printf("error signing alicetx numinputs.%d\n",spend->numinputs);
free(spend);

Loading…
Cancel
Save