From 2b2173daab4f6a4579ce2e600fa4fb2fc7d7b75c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 4 Jun 2017 17:20:15 +0300 Subject: [PATCH] Test --- iguana/exchanges/LP_commands.c | 5 ++--- iguana/exchanges/LP_transaction.c | 8 +++++++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index 70cfedd82..d9a343110 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -113,9 +113,8 @@ int32_t LP_quoteparse(struct LP_quoteinfo *qp,cJSON *argjson) qp->desthash = jbits256(argjson,"desthash"); if ( (qp->satoshis= j64bits(argjson,"satoshis")) == 0 ) qp->satoshis = SATOSHIDEN * jdouble(argjson,"value"); - if ( (qp->satoshis2= j64bits(argjson,"satoshis2")) == 0 ) - qp->satoshis = SATOSHIDEN * jdouble(argjson,"value2"); - qp->destsatoshis = j64bits(argjson,"destsatoshis"); + if ( (qp->destsatoshis= j64bits(argjson,"destsatoshis")) == 0 ) + qp->destsatoshis = SATOSHIDEN * jdouble(argjson,"value2"); qp->change = SATOSHIDEN * jdouble(argjson,"change"); qp->txfee = j64bits(argjson,"txfee"); qp->desttxfee = j64bits(argjson,"desttxfee"); diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index d5cded1ad..42ffb64d2 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -639,6 +639,12 @@ char *basilisk_swap_bobtxspend(bits256 *signedtxidp,uint64_t txfee,char *name,ch if ( addrtype == p2shtype ) spendlen = bitcoin_p2shspend(spendscript,0,rmd160); else spendlen = bitcoin_standardspend(spendscript,0,rmd160); + if ( change != 0 && strcmp(changeaddr,destaddr) == 0 ) + { + printf("combine change %.8f -> %s\n",dstr(change),changeaddr); + satoshis += change; + change = 0; + } txobj = bitcoin_txoutput(txobj,spendscript,spendlen,satoshis); if ( change != 0 ) { @@ -722,7 +728,7 @@ int32_t basilisk_rawtx_sign(char *symbol,uint8_t pubtype,uint8_t p2shtype,uint8_ } for (iter=0; iter<2; iter++) { - if ( (signedtx= basilisk_swap_bobtxspend(&dest->I.signedtxid,iter == 0 ? txfee : newtxfee,rawtx->name,symbol,pubtype,p2shtype,isPoS,wiftype,swap->ctx,privkey,privkey2,rawtx->redeemscript,rawtx->I.redeemlen,userdata,userdatalen,rawtx->utxotxid,rawtx->utxovout,dest->p2shaddr,rawtx->I.pubkey33,1,0,&destamount,rawtx->I.amount,changeaddr,vinaddr,dest->I.suppress_pubkeys)) != 0 ) + if ( (signedtx= basilisk_swap_bobtxspend(&dest->I.signedtxid,iter == 0 ? txfee : newtxfee,rawtx->name,symbol,pubtype,p2shtype,isPoS,wiftype,swap->ctx,privkey,privkey2,rawtx->redeemscript,rawtx->I.redeemlen,userdata,userdatalen,rawtx->utxotxid,rawtx->utxovout,dest->I.destaddr,rawtx->I.pubkey33,1,0,&destamount,rawtx->I.amount,changeaddr,vinaddr,dest->I.suppress_pubkeys)) != 0 ) { dest->I.datalen = (int32_t)strlen(signedtx) >> 1; if ( dest->I.datalen <= sizeof(dest->txbytes) )