From c8f658875b971a135c4de018942da2246849dffc Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 23 Feb 2018 21:06:06 +0200 Subject: [PATCH] Test --- iguana/exchanges/LP_bitcoin.c | 1 - iguana/exchanges/LP_remember.c | 18 +++++------------- iguana/exchanges/LP_transaction.c | 22 +++++++++++----------- 3 files changed, 16 insertions(+), 25 deletions(-) diff --git a/iguana/exchanges/LP_bitcoin.c b/iguana/exchanges/LP_bitcoin.c index 691ab3e19..666f96d3e 100644 --- a/iguana/exchanges/LP_bitcoin.c +++ b/iguana/exchanges/LP_bitcoin.c @@ -1913,7 +1913,6 @@ int32_t bitcoin_p2shspend(uint8_t *script,int32_t n,uint8_t rmd160[20]) int32_t bitcoin_secret160verify(uint8_t *script,int32_t n,uint8_t secret160[20]) { script[n++] = IGUANA_OP_SIZE; // add SIZE 32 EQUALVERIFY - script[n++] = IGUANA_OP_PUSHDATA1; script[n++] = 1; script[n++] = 32; script[n++] = SCRIPT_OP_EQUALVERIFY; diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index 7a9806609..cf9044d22 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -1200,12 +1200,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti memset(rev.bytes,0,sizeof(rev)); for (j=0; j<32; j++) rev.bytes[j] = rswap.privAm.bytes[31 - j]; - //revcalc_rmd160_sha256(secretAm,rev);//privAm); - //vcalc_sha256(0,secretAm256,rev.bytes,sizeof(rev)); - //if ( rswap.Predeemlen != 0 ) - // redeemlen = rswap.Predeemlen, memcpy(redeemscript,rswap.Predeemscript,rswap.Predeemlen); - //else - redeemlen = basilisk_swap_bobredeemscript(0,&secretstart,redeemscript,rswap.plocktime,rswap.pubA0,rswap.pubB0,rswap.pubB1,rev,rswap.privBn,rswap.secretAm,rswap.secretAm256,rswap.secretBn,rswap.secretBn256); + redeemlen = basilisk_swap_bobredeemscript(0,&secretstart,redeemscript,rswap.plocktime,rswap.pubA0,rswap.pubB0,rswap.pubB1,rev,rswap.privBn,rswap.secretAm,rswap.secretAm256,rswap.secretBn,rswap.secretBn256); if ( rswap.Predeemlen != 0 ) { if ( rswap.Predeemlen != redeemlen || memcmp(redeemscript,rswap.Predeemscript,redeemlen) != 0 ) @@ -1213,17 +1208,14 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti else printf("Predeem matches\n"); } else printf("%p Predeemscript missing\n",rswap.Predeemscript); len = basilisk_swapuserdata(userdata,rev,0,rswap.myprivs[0],redeemscript,redeemlen); + if ( 0 ) { - char privaddr[64]; uint8_t privpub33[33],secretAm[20]; - revcalc_rmd160_sha256(secretAm,rev); + uint8_t secretAm[20]; + calc_rmd160_sha256(secretAm,rswap.privAm.bytes,sizeof(rswap.privAm)); for (j=0; j<20; j++) printf("%02x",secretAm[j]); - bitcoin_pubkey33(ctx,privpub33,rswap.myprivs[0]); - bitcoin_address(rswap.bobcoin,privaddr,0,60,privpub33,33); - printf(" alicespend len.%d redeemlen.%d priv0addr.(%s) priv0.(%s)\n",len,redeemlen,privaddr,bits256_str(str,rswap.myprivs[0])); + printf(" secretAm, privAm %s alicespend len.%d redeemlen.%d\n",bits256_str(str,rswap.privAm),len,redeemlen); } - for (j=0; j<32; j++) - rev.bytes[j] = rswap.myprivs[0].bytes[31 - j]; if ( (rswap.txbytes[BASILISK_ALICESPEND]= basilisk_swap_bobtxspend(&signedtxid,rswap.Btxfee,"alicespend",rswap.bobcoin,bob->wiftaddr,bob->taddr,bob->pubtype,bob->p2shtype,bob->isPoS,bob->wiftype,ctx,rswap.myprivs[0],0,redeemscript,redeemlen,userdata,len,rswap.txids[BASILISK_BOBPAYMENT],0,0,rswap.pubkey33,1,rswap.expiration,&rswap.values[BASILISK_ALICESPEND],0,0,rswap.bobpaymentaddr,1,bob->zcash)) != 0 ) { printf("alicespend.(%s)\n",rswap.txbytes[BASILISK_ALICESPEND]); diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index d3c0f9c58..010b08aaf 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -1788,17 +1788,17 @@ int32_t basilisk_swap_bobredeemscript(int32_t depositflag,int32_t *secretstartp, uint8_t bufA[20],bufB[20]; revcalc_rmd160_sha256(bufA,privkey); calc_rmd160_sha256(bufB,privkey.bytes,sizeof(privkey)); - if ( memcmp(bufA,secret160,sizeof(bufA)) == 0 ) - printf("MATCHES BUFA\n"); - else if ( memcmp(bufB,secret160,sizeof(bufB)) == 0 ) - printf("MATCHES BUFB\n"); - else printf("secret160 matches neither\n"); - for (i=0; i<20; i++) - printf("%02x",bufA[i]); - printf(" <- revcalc\n"); - for (i=0; i<20; i++) - printf("%02x",bufB[i]); - printf(" <- calc\n"); + /*if ( memcmp(bufA,secret160,sizeof(bufA)) == 0 ) + printf("MATCHES BUFA\n"); + else if ( memcmp(bufB,secret160,sizeof(bufB)) == 0 ) + printf("MATCHES BUFB\n"); + else printf("secret160 matches neither\n"); + for (i=0; i<20; i++) + printf("%02x",bufA[i]); + printf(" <- revcalc\n"); + for (i=0; i<20; i++) + printf("%02x",bufB[i]); + printf(" <- calc\n");*/ memcpy(secret160,bufB,20); } n = bitcoin_secret160verify(redeemscript,n,secret160);