diff --git a/basilisk/basilisk_swap.c b/basilisk/basilisk_swap.c index 90c8c3579..da4d81dff 100755 --- a/basilisk/basilisk_swap.c +++ b/basilisk/basilisk_swap.c @@ -105,15 +105,19 @@ int32_t basilisk_bobscript(uint8_t *rmd160,uint8_t *redeemscript,int32_t *redeem return(n); } -int32_t basilisk_alicescript(uint8_t *script,int32_t n,char *msigaddr,uint8_t altps2h,bits256 pubAm,bits256 pubBn) +int32_t basilisk_alicescript(uint8_t *redeemscript,int32_t *redeemlenp,uint8_t *script,int32_t n,char *msigaddr,uint8_t altps2h,bits256 pubAm,bits256 pubBn) { - uint8_t p2sh160[20]; struct vin_info V; + uint8_t i,p2sh160[20]; struct vin_info V; memset(&V,0,sizeof(V)); memcpy(&V.signers[0].pubkey[1],pubAm.bytes,sizeof(pubAm)), V.signers[0].pubkey[0] = 0x02; memcpy(&V.signers[1].pubkey[1],pubBn.bytes,sizeof(pubBn)), V.signers[1].pubkey[0] = 0x03; V.M = V.N = 2; - n = bitcoin_MofNspendscript(p2sh160,script,n,&V); + *redeemlenp = bitcoin_MofNspendscript(p2sh160,redeemscript,n,&V); bitcoin_address(msigaddr,altps2h,p2sh160,sizeof(p2sh160)); + n = bitcoin_p2shspend(script,0,p2sh160); + for (i=0; ispendlen = basilisk_alicescript(alicepayment->spendscript,0,alicepayment->destaddr,coin->chain->p2shtype,pubAm,pubBn); + alicepayment->spendlen = basilisk_alicescript(alicepayment->redeemscript,&alicepayment->redeemlen,alicepayment->spendscript,0,alicepayment->destaddr,coin->chain->p2shtype,pubAm,pubBn); basilisk_rawtx_gen("alicepayment",myinfo,0,1,alicepayment,alicepayment->locktime,alicepayment->spendscript,alicepayment->spendlen,coin->chain->txfee,1); } diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 7068d46df..7f954cc8d 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -423,7 +423,7 @@ void iguana_update_balances(struct iguana_info *coin) return; } max = coin->bundlescount; - if ( coin->bundles[max-1] != 0 && coin->bundles[max-1]->emitfinish <= 1 && coin->RTheight == 0 ) + if ( coin->bundles[max-1] == coin->current || coin->bundles[max-1] == 0 || (coin->bundles[max-1] != 0 && coin->bundles[max-1]->emitfinish <= 1) ) max--; //coin->spendvectorsaved = 0; if ( iguana_balancefinished(coin) < max && iguana_spendvectorsaves(coin) == 0 ) // diff --git a/iguana/iguana_spendvectors.c b/iguana/iguana_spendvectors.c index 2a261cd8f..065dbd694 100755 --- a/iguana/iguana_spendvectors.c +++ b/iguana/iguana_spendvectors.c @@ -56,7 +56,7 @@ int32_t iguana_spendvectorsave(struct iguana_info *coin,struct iguana_bundle *bp int32_t i,retval = -1; FILE *fp; char fname[1024],str[65]; long fsize; bits256 zero,sha256; if ( ptr == 0 || (bp->hdrsi != 0 && ptr == bp->ramchain.Xspendinds) ) { - //printf("iguana_spendvectorsave.[%d] ptr.%p Xspendinds\n",bp->hdrsi,ptr); + printf("iguana_spendvectorsave.[%d] ptr.%p Xspendinds\n",bp->hdrsi,ptr); return(0); } memset(zero.bytes,0,sizeof(zero)); @@ -72,7 +72,7 @@ int32_t iguana_spendvectorsave(struct iguana_info *coin,struct iguana_bundle *bp { if ( fwrite(sha256.bytes,1,sizeof(sha256),fp) != sizeof(sha256) ) printf("error writing hash for %d -> (%s)\n",(int32_t)(sizeof(*ptr) * emit),fname); - else if ( fwrite(ptr,sizeof(*ptr),emit,fp) != emit ) + else if ( emit != 0 && fwrite(ptr,sizeof(*ptr),emit,fp) != emit ) printf("error writing %d of %d -> (%s)\n",emit,n,fname); else { @@ -84,7 +84,7 @@ int32_t iguana_spendvectorsave(struct iguana_info *coin,struct iguana_bundle *bp printf("error mapping Xspendmap.(%s)\n",fname); else { - //printf("created.(%s) %p[%d]\n",fname,bp->ramchain.Xspendinds,bp->ramchain.numXspends); + printf("created.(%s) %p[%d]\n",fname,bp->ramchain.Xspendinds,bp->ramchain.numXspends); retval = 0; } } @@ -93,8 +93,7 @@ int32_t iguana_spendvectorsave(struct iguana_info *coin,struct iguana_bundle *bp //int32_t i; for (i=0; inumXspends; i++) // printf("(%d u%d) ",ramchain->Xspendinds[i].hdrsi,ramchain->Xspendinds[i].ind); //printf("filesize %ld Xspendptr.%p %p num.%d\n",fsize,ramchain->Xspendptr,ramchain->Xspendinds,ramchain->numXspends); - } - else printf("iguana_spendvectors: Error creating.(%s)\n",fname); + } else printf("iguana_spendvectors: Error creating.(%s)\n",fname); return(retval); }