diff --git a/basilisk/basilisk_swap.c b/basilisk/basilisk_swap.c index 678c71dab..3f7f4b0b8 100755 --- a/basilisk/basilisk_swap.c +++ b/basilisk/basilisk_swap.c @@ -55,6 +55,14 @@ //auto create utxo +void revcalc_rmd160_sha256(uint8_t rmd160[20],bits256 revhash) +{ + bits256 hash; int32_t i; + for (i=0; i<32; i++) + hash.bytes[i] = revhash.bytes[31-i]; + calc_rmd160_sha256(rmd160,hash.bytes,sizeof(hash)); +} + #define SCRIPT_OP_IF 0x63 #define SCRIPT_OP_ELSE 0x67 #define SCRIPT_OP_ENDIF 0x68 @@ -449,7 +457,7 @@ int32_t basilisk_verify_privi(struct supernet_info *myinfo,void *ptr,uint8_t *da { for (j=0; j<32; j++) privkey.bytes[j] = data[len++]; - calc_rmd160_sha256(secret160,privkey.bytes,sizeof(privkey)); + revcalc_rmd160_sha256(secret160,privkey);//.bytes,sizeof(privkey)); memcpy(&txid,secret160,sizeof(txid)); pubi = bitcoin_pubkey33(myinfo->ctx,pubkey33,privkey); if ( basilisk_verify_pubpair(&wrongfirstbyte,swap,swap->choosei,pubkey33[0],pubi,txid) == 0 ) @@ -638,7 +646,7 @@ int32_t instantdex_pubkeyargs(struct supernet_info *myinfo,struct basilisk_swap if ( m < INSTANTDEX_DECKSIZE ) { swap->privkeys[m] = privkey; - calc_rmd160_sha256(secret160,privkey.bytes,sizeof(privkey)); + revcalc_rmd160_sha256(secret160,privkey);//.bytes,sizeof(privkey)); memcpy(&txid,secret160,sizeof(txid)); len += iguana_rwnum(1,(uint8_t *)&swap->deck[m][0],sizeof(txid),&txid); len += iguana_rwnum(1,(uint8_t *)&swap->deck[m][1],sizeof(pubi.txid),&pubi.txid); @@ -1053,7 +1061,7 @@ int32_t basilisk_verify_privkeys(struct supernet_info *myinfo,void *ptr,uint8_t if ( i != swap->choosei ) { pubi = bitcoin_pubkey33(myinfo->ctx,otherpubkey,otherpriv); - calc_rmd160_sha256(secret160,otherpriv.bytes,sizeof(otherpriv)); + revcalc_rmd160_sha256(secret160,otherpriv);//.bytes,sizeof(otherpriv)); memcpy(&txid,secret160,sizeof(txid)); errs += basilisk_verify_pubpair(&wrongfirstbyte,swap,i,otherpubkey[0],pubi,txid); } @@ -1159,7 +1167,7 @@ void basilisk_waitchoosei(struct supernet_info *myinfo,struct basilisk_swap *swa { swap->privBn = swap->privkeys[swap->otherchoosei]; memset(&swap->privkeys[swap->otherchoosei],0,sizeof(swap->privkeys[swap->otherchoosei])); - calc_rmd160_sha256(swap->secretBn,swap->privBn.bytes,sizeof(swap->privBn)); + revcalc_rmd160_sha256(swap->secretBn,swap->privBn);//.bytes,sizeof(swap->privBn)); swap->pubBn = bitcoin_pubkey33(myinfo->ctx,pubkey33,swap->privBn); printf("set privBn.%s\n",bits256_str(str,swap->privBn)); } @@ -1170,7 +1178,7 @@ void basilisk_waitchoosei(struct supernet_info *myinfo,struct basilisk_swap *swa { swap->privAm = swap->privkeys[swap->otherchoosei]; memset(&swap->privkeys[swap->otherchoosei],0,sizeof(swap->privkeys[swap->otherchoosei])); - calc_rmd160_sha256(swap->secretAm,swap->privAm.bytes,sizeof(swap->privAm)); + revcalc_rmd160_sha256(swap->secretAm,swap->privAm);//.bytes,sizeof(swap->privAm)); swap->pubAm = bitcoin_pubkey33(myinfo->ctx,pubkey33,swap->privAm); printf("set privAm.%s\n",bits256_str(str,swap->privAm)); } diff --git a/iguana/iguana_interpreter.c b/iguana/iguana_interpreter.c index 73cfa7d20..7aab18c1c 100755 --- a/iguana/iguana_interpreter.c +++ b/iguana/iguana_interpreter.c @@ -1337,7 +1337,7 @@ int32_t bitcoin_assembler(struct iguana_info *coin,cJSON *logarray,uint8_t scrip } else if ( (op->flags & IGUANA_CRYPTOFLAG) != 0 ) { - uint8_t revrmd160[20],rmd160[20]; bits256 hash; + uint8_t rmd160[20]; bits256 hash; datalen = iguana_databuf(databuf,args[0]); switch ( op->opcode ) { @@ -1350,14 +1350,8 @@ int32_t bitcoin_assembler(struct iguana_info *coin,cJSON *logarray,uint8_t scrip iguana_pushdata(stacks,0,rmd160,sizeof(rmd160)); break; case IGUANA_OP_HASH160: - calc_rmd160_sha256(revrmd160,databuf,datalen); - for (i=0; i<20; i++) - { - rmd160[i] = revrmd160[19-i]; - printf("%02x",revrmd160[i]); - } - printf(" <- rev OP_HASH160\n"); - iguana_pushdata(stacks,0,revrmd160,sizeof(rmd160)); + calc_rmd160_sha256(rmd160,databuf,datalen); + iguana_pushdata(stacks,0,rmd160,sizeof(rmd160)); break; case IGUANA_OP_SHA256: vcalc_sha256(0,hash.bytes,databuf,datalen); diff --git a/iguana/iguana_scripts.c b/iguana/iguana_scripts.c index adcc507e5..accdf3dc9 100755 --- a/iguana/iguana_scripts.c +++ b/iguana/iguana_scripts.c @@ -36,11 +36,8 @@ int32_t bitcoin_p2shspend(uint8_t *script,int32_t n,uint8_t rmd160[20]) int32_t bitcoin_revealsecret160(uint8_t *script,int32_t n,uint8_t secret160[20]) { - //int32_t i; script[n++] = SCRIPT_OP_HASH160; script[n++] = 0x14; - //for (i=0; i<20; i++) - // script[n+i] = secret160[19-i]; memcpy(&script[n],secret160,0x14); n += 0x14; script[n++] = SCRIPT_OP_EQUALVERIFY;