From 470435599bb0b833237b3e4ae40919952d8c07df Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 19 Jan 2017 19:12:00 +0200 Subject: [PATCH] test --- basilisk/basilisk.h | 1 + basilisk/basilisk_DEX.c | 20 ++++++++++++++++++++ basilisk/basilisk_swap.c | 22 +++++++++++++++++----- iguana/tests/dexsendrawtransaction | 2 +- includes/iguana_apideclares.h | 4 ++-- 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/basilisk/basilisk.h b/basilisk/basilisk.h index bc90e01ce..eeb343919 100755 --- a/basilisk/basilisk.h +++ b/basilisk/basilisk.h @@ -143,5 +143,6 @@ int32_t basilisk_bobscripts_set(struct supernet_info *myinfo,struct basilisk_swa void basilisk_txlog(struct supernet_info *myinfo,struct basilisk_swap *swap,struct basilisk_rawtx *rawtx,int32_t delay); int32_t basilisk_messagekey(uint8_t *key,uint32_t channel,uint32_t msgid,bits256 srchash,bits256 desthash); cJSON *basilisk_unspents(struct supernet_info *myinfo,struct iguana_info *coin,char *coinaddr); +char *basilisk_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *signedtx); #endif diff --git a/basilisk/basilisk_DEX.c b/basilisk/basilisk_DEX.c index 04a64f1d5..a126f20df 100755 --- a/basilisk/basilisk_DEX.c +++ b/basilisk/basilisk_DEX.c @@ -580,6 +580,26 @@ cJSON *basilisk_unspents(struct supernet_info *myinfo,struct iguana_info *coin,c return(unspents); } +char *basilisk_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *signedtx) +{ + char *retstr,buf[65]; bits256 txid; + if ( coin->FULLNODE > 0 ) + { + txid = iguana_sendrawtransaction(myinfo,coin,signedtx); + if ( bits256_nonz(txid) ) + { + bits256_str(buf,txid); + retstr = clonestr(buf); + } else retstr = clonestr("{\"error\":\"couldnt validate or send signedtx\"}"); + } + else if ( coin->FULLNODE == 0 ) + { + retstr = _dex_sendrawtransaction(myinfo,coin->symbol,signedtx); + } + else retstr = dpow_sendrawtransaction(myinfo,coin,signedtx); + return(retstr); +} + STRING_ARG(InstantDEX,available,source) { uint64_t total = 0; int32_t i,n=0; char coinaddr[64]; cJSON *item,*unspents,*retjson = 0; diff --git a/basilisk/basilisk_swap.c b/basilisk/basilisk_swap.c index 15c944a2e..62ca30150 100755 --- a/basilisk/basilisk_swap.c +++ b/basilisk/basilisk_swap.c @@ -18,7 +18,7 @@ // more better LP commands // depends on just three external functions: -// - iguana_sendrawtransaction(myinfo,coin,signedtx); +// - basilisk_sendrawtransaction(myinfo,coin,signedtx); // - basilisk_value(myinfo,rawtx->coin,0,0,myinfo->myaddr.persistent,argjson,0) // basilisk_bitcoinrawtx(myinfo,rawtx->coin,"",basilisktag,jint(valsobj,"timeout"),valsobj,V) @@ -279,7 +279,7 @@ int32_t basilisk_numconfirms(struct supernet_info *myinfo,struct basilisk_rawtx bits256 basilisk_swap_broadcast(char *name,struct supernet_info *myinfo,struct basilisk_swap *swap,struct iguana_info *coin,uint8_t *data,int32_t datalen) { - bits256 txid; char *signedtx; + bits256 txid; char *signedtx,*retstr; memset(txid.bytes,0,sizeof(txid)); if ( data != 0 && datalen != 0 ) { @@ -291,8 +291,20 @@ bits256 basilisk_swap_broadcast(char *name,struct supernet_info *myinfo,struct b #endif signedtx = malloc(datalen*2 + 1); init_hexbytes_noT(signedtx,data,datalen); - txid = iguana_sendrawtransaction(myinfo,coin,signedtx); - printf("sendrawtransaction %s.(%s)\n",name,bits256_str(str,txid)); + if ( (retstr= basilisk_sendrawtransaction(myinfo,coin,signedtx)) != 0 ) + { + if ( is_hexstr(retstr,0) == 64 ) + { + decode_hex(txid.bytes,32,retstr); + free(retstr); + printf("sendrawtransaction %s.(%s)\n",name,bits256_str(str,txid)); + } + else + { + printf("sendrawtransaction %s error.(%s)\n",name,retstr); + free(retstr); + } + } else printf("sendrawtransaction %s got null return\n",name); free(signedtx); } return(txid); @@ -1367,7 +1379,7 @@ uint32_t basilisk_swapdata_rawtxsend(struct supernet_info *myinfo,struct basilis { char str[65],str2[65]; rawtx->I.actualtxid = basilisk_swap_broadcast(rawtx->name,myinfo,swap,rawtx->coin,rawtx->txbytes,rawtx->I.datalen); - if ( bits256_nonz(rawtx->I.actualtxid) == 0 ) + if ( bits256_cmp(rawtx->I.actualtxid,rawtx->I.signedtxid) != 0 ) printf("%s rawtxsend %s vs %s\n",rawtx->name,bits256_str(str,rawtx->I.signedtxid),bits256_str(str2,rawtx->I.actualtxid)); if ( bits256_nonz(rawtx->I.actualtxid) != 0 && msgbits != 0 ) { diff --git a/iguana/tests/dexsendrawtransaction b/iguana/tests/dexsendrawtransaction index a5eb92cac..d60706f4d 100755 --- a/iguana/tests/dexsendrawtransaction +++ b/iguana/tests/dexsendrawtransaction @@ -1,2 +1,2 @@ #!/bin/bash -curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"sendrawtransaction\",\"signedtx\":\"aa82ebd1c5bd2a9e19214cbc959df1745378676fddfd6f4903930ac16485c7ae\",\"symbol\":\"BTC\"}" +curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"sendrawtransaction\",\"signedtx\":\"0100000001372105704c1303f4c928b788becce75b653b5e83d56fc25893f682875f9df00e010000006a47304402203c3e71c309fcf70d1b1b42207824b37cfec918930000b8d812844be9a8d06bae02202eafe0515f6cd775ba06be0fab6cea667a23508e69334310b959ebd7eade38c9012102320228e3f6f9b8db3d905bc21cefde46e72d622021b8fd40344ac2ab8346c287ffffffff02b0e20d000000000017a914077fa9d41d53cc38118b8280e97e4aee576d6e5a87c08c8a00000000001976a914838f4ea2f88f24b87247b72a1d66da225653e39788ac00000000\",\"symbol\":\"USD\"}" diff --git a/includes/iguana_apideclares.h b/includes/iguana_apideclares.h index 859aae5b8..1449b0ff8 100755 --- a/includes/iguana_apideclares.h +++ b/includes/iguana_apideclares.h @@ -21,7 +21,7 @@ ZERO_ARGS(dpow,cancelratify); STRING_ARG(dpow,bindaddr,ipaddr); STRING_AND_INT(dpow,fundnotaries,symbol,numblocks); -ZERO_ARGS(passthru,paxfiats); +INT_ARG(passthru,paxfiats,mask); @@ -63,7 +63,7 @@ TWO_INTS(InstantDEX,accept,requestid,quoteid); HASH_ARRAY_STRING(basilisk,genesis_opreturn,hash,vals,hexstr); HASH_ARRAY_STRING(basilisk,history,hash,vals,hexstr); -ZERO_ARGS(basilisk,paxfiats); +INT_ARG(basilisk,paxfiats,mask); HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr); HASH_ARRAY_STRING(basilisk,value,hash,vals,hexstr); HASH_ARRAY_STRING(basilisk,rawtx,hash,vals,hexstr);