From 0919bb11077f573ce5f8858d5b747879d18e233e Mon Sep 17 00:00:00 2001 From: jl777 <jameslee777@yahoo.com> Date: Fri, 20 Oct 2017 14:42:31 +0300 Subject: [PATCH] Error check withdraw amount --- iguana/exchanges/LP_nativeDEX.c | 2 +- iguana/exchanges/LP_transaction.c | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index e92bee830..bb2f850fa 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -19,12 +19,12 @@ // marketmaker // // sign critical api calls (pubkey reg, listunspent, orders?) -// dPoW security -> 4: KMD notarized, 5: BTC notarized // process stats.log local file -> map of realtime activity! // handles <-> pubkeys, deal with offline pubkeys, reputations, bonds etc. // // alice only coins GAME UNO BTM ANC: GAME BTCD PPC RDD XZC POT EAC FTC BASH SPR WDC UNO XPM XCN BELA CHC DIME MEC NAUT MED AUR MAX DGC RIC EB3 DOT BTM GEO ANC CANN ICASH WBB SRC PTC ADZ TIPS EQT START EFL FST FJC NYC GCN // verify portfolio, pricearray, interest to KMD withdraw +// dPoW security -> 4: KMD notarized, 5: BTC notarized #include <stdio.h> diff --git a/iguana/exchanges/LP_transaction.c b/iguana/exchanges/LP_transaction.c index 0c45df38c..f6f6314c7 100644 --- a/iguana/exchanges/LP_transaction.c +++ b/iguana/exchanges/LP_transaction.c @@ -923,6 +923,12 @@ char *LP_createrawtransaction(cJSON **txobjp,int32_t *numvinsp,struct iguana_inf suppress_pubkeys = 1; scriptlen = bitcoin_standardspend(script,0,G.LP_myrmd160); numvins = LP_vins_select(ctx,coin,&total,amount,V,utxos,numutxos,suppress_pubkeys,ignore_cltverr,privkey,privkeys,vins,script,scriptlen); + if ( total < amount ) + { + printf("change %.8f = total %.8f - amount %.8f, adjust %.8f numvouts.%d, txfee %.8f\n",dstr(change),dstr(total),dstr(amount),dstr(adjust),numvouts,dstr(txfee)); + printf("not enough inputs for amount %.8f < %.8f txfee %.8f\n",dstr(total),dstr(amount),dstr(txfee)); + return(0); + } change = (total - amount); timestamp = (uint32_t)time(NULL); if ( strcmp("KMD",coin->symbol) == 0 ) @@ -936,6 +942,7 @@ char *LP_createrawtransaction(cJSON **txobjp,int32_t *numvinsp,struct iguana_inf adjust = change / numvouts; change = 0; } + printf("change %.8f = total %.8f - amount %.8f, adjust %.8f numvouts.%d\n",dstr(change),dstr(total),dstr(amount),dstr(adjust),numvouts); for (i=0; i<numvouts; i++) { item = jitem(outputs,i);