From 015b4cec17a75154bd4ef5f3bc0ab907284a8588 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 19 Apr 2018 10:30:38 +0300 Subject: [PATCH 1/3] cancel_order(uuid) api --- iguana/exchanges/LP_commands.c | 5 +++++ iguana/exchanges/LP_ordermatch.c | 11 +++++++++++ 2 files changed, 16 insertions(+) diff --git a/iguana/exchanges/LP_commands.c b/iguana/exchanges/LP_commands.c index fe548f12a0..8263111c69 100644 --- a/iguana/exchanges/LP_commands.c +++ b/iguana/exchanges/LP_commands.c @@ -116,6 +116,7 @@ pricearray(base, rel, starttime=0, endtime=0, timescale=60) -> [timestamp, avebi getrawtransaction(coin, txid)\n\ inventory(coin, reset=0, [passphrase=])\n\ lastnonce()\n\ +cancel(uuid)\n\ buy(base, rel, price, relvolume, timeout=10, duration=3600, nonce)\n\ sell(base, rel, price, basevolume, timeout=10, duration=3600, nonce)\n\ withdraw(coin, outputs[], broadcast=0)\n\ @@ -304,6 +305,10 @@ jpg(srcfile, destfile, power2=7, password, data="", required, ind=0)\n\ LP_deletemessages(jint(argjson,"firsti"),jint(argjson,"num")); return(clonestr("{\"result\":\"success\"}")); }*/ + else if ( strcmp(method,"cancel") == 0 ) + { + return(LP_cancel_order(jstr(argjson,"uuid"))); + } else if ( strcmp(method,"recentswaps") == 0 ) { return(LP_recent_swaps(jint(argjson,"limit"),0)); diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 346287e6b1..81b92cf717 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -623,6 +623,17 @@ int32_t LP_alice_eligible(uint32_t quotetime) return(Alice_expiration == 0 || time(NULL) < Alice_expiration); } +char *LP_cancel_order(char *uuidstr) +{ + if ( uuidstr != 0 && strcmp(LP_Alicequery.uuidstr[0],uuidstr) == 0 ) + { + LP_failedmsg(LP_Alicequery.R.requestid,LP_Alicequery.R.quoteid,-9998,LP_Alicequery.uuidstr); + LP_alicequery_clear(); + clonestr("{\"result\":\"success\",\"status\":\"uuid canceled\"}") + } + return(clonestr("{\"error\":\"uuid not cancellable\"}")); +} + char *LP_connectedalice(struct LP_quoteinfo *qp,char *pairstr) // alice { cJSON *retjson; char otheraddr[64],*msg; double bid,ask,price,qprice; int32_t pairsock = -1; int32_t DEXselector = 0; struct LP_utxoinfo *autxo,A,B,*butxo; struct basilisk_swap *swap; struct iguana_info *coin; From 581ed0cc40ea15a387427087cdeb49455449fbd2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 19 Apr 2018 10:31:49 +0300 Subject: [PATCH 2/3] syntax --- iguana/exchanges/LP_ordermatch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index 81b92cf717..a6c928a0af 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -625,11 +625,11 @@ int32_t LP_alice_eligible(uint32_t quotetime) char *LP_cancel_order(char *uuidstr) { - if ( uuidstr != 0 && strcmp(LP_Alicequery.uuidstr[0],uuidstr) == 0 ) + if ( uuidstr != 0 && strcmp(LP_Alicequery.uuidstr,uuidstr) == 0 ) { LP_failedmsg(LP_Alicequery.R.requestid,LP_Alicequery.R.quoteid,-9998,LP_Alicequery.uuidstr); LP_alicequery_clear(); - clonestr("{\"result\":\"success\",\"status\":\"uuid canceled\"}") + clonestr("{\"result\":\"success\",\"status\":\"uuid canceled\"}"); } return(clonestr("{\"error\":\"uuid not cancellable\"}")); } From d85538ed21523ce40e535b898155d65dc63c3d44 Mon Sep 17 00:00:00 2001 From: Luke Childs Date: Thu, 19 Apr 2018 16:03:01 +0800 Subject: [PATCH 3/3] Fix missing early return bug in LP_cancel_order --- iguana/exchanges/LP_ordermatch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index a6c928a0af..ed2425f2c4 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -629,7 +629,7 @@ char *LP_cancel_order(char *uuidstr) { LP_failedmsg(LP_Alicequery.R.requestid,LP_Alicequery.R.quoteid,-9998,LP_Alicequery.uuidstr); LP_alicequery_clear(); - clonestr("{\"result\":\"success\",\"status\":\"uuid canceled\"}"); + return(clonestr("{\"result\":\"success\",\"status\":\"uuid canceled\"}")); } return(clonestr("{\"error\":\"uuid not cancellable\"}")); }