From b9cb9227c21638cc2a135b1150a2b4c3a255b56d Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 26 Jan 2017 10:15:04 +0200 Subject: [PATCH] test --- iguana/iguana_payments.c | 33 +++++++++++++++++++++++++++++++-- iguana/tests/dexgetO | 2 +- iguana/tests/dexgetT | 2 +- iguana/tests/dexlistunspent | 2 +- iguana/tests/dexvalidate | 2 +- 5 files changed, 35 insertions(+), 6 deletions(-) diff --git a/iguana/iguana_payments.c b/iguana/iguana_payments.c index fe8e1d19b..c66a367d7 100755 --- a/iguana/iguana_payments.c +++ b/iguana/iguana_payments.c @@ -1220,7 +1220,7 @@ HASH_ARG(bitcoinrpc,gettransaction,txid) cJSON *iguana_createvins(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *txobj,cJSON *vins) { - int32_t i,n,vout,p2shlen=0,spendlen=0,height; uint64_t satoshis; char coinaddr[128],pubkeystr[256],scriptstr[IGUANA_MAXSCRIPTSIZE*2],*str,*hexstr; cJSON *pubkeys,*item,*obj,*newvin,*newvins; uint32_t sequenceid; bits256 txid; uint8_t spendscript[IGUANA_MAXSCRIPTSIZE],redeemscript[IGUANA_MAXSCRIPTSIZE]; struct iguana_waccount *wacct; struct iguana_waddress *waddr; struct iguana_outpoint outpt; + int32_t i,j,n,vout,p2shlen=0,spendlen=0,height; uint64_t satoshis; char coinaddr[128],pubkeystr[256],scriptstr[IGUANA_MAXSCRIPTSIZE*2],*str,*hexstr; cJSON *pubkeys,*item,*obj,*newvin,*newvins; uint32_t sequenceid; bits256 txid; uint8_t spendscript[IGUANA_MAXSCRIPTSIZE],redeemscript[IGUANA_MAXSCRIPTSIZE]; struct iguana_waccount *wacct; struct iguana_waddress *waddr; struct iguana_outpoint outpt; newvins = cJSON_CreateArray(); if ( (n= cJSON_GetArraySize(vins)) > 0 ) { @@ -1244,7 +1244,36 @@ cJSON *iguana_createvins(struct supernet_info *myinfo,struct iguana_info *coin,c spendlen = (int32_t)strlen(hexstr) >> 1; decode_hex(spendscript,spendlen,hexstr); } - if ( iguana_RTunspentindfind(myinfo,coin,&outpt,coinaddr,spendscript,&spendlen,&satoshis,&height,txid,vout,coin->bundlescount-1,0) == 0 ) + if ( coin->FULLNODE == 0 && coin->notarychain >= 0 ) + { + char *retstr; cJSON *txoutjson,*sobj,*array; int32_t numaddrs; + if ( (retstr= _dex_gettxout(myinfo,coin->symbol,txid,vout)) != 0 ) + { + // {"bestblock":"000000000000000002a530b32efce4cb4ee01b401d58592ce36939d84c9f94b9","confirmations":109,"value":0.00120000,"scriptPubKey":{"asm":"OP_DUP OP_HASH160 971f98b33fb838faee190e2fab799440d8c51702 OP_EQUALVERIFY OP_CHECKSIG","hex":"76a914971f98b33fb838faee190e2fab799440d8c5170288ac","reqSigs":1,"type":"pubkeyhash","addresses":["1En4tL4drN5qAZDtu1BCC7DThj58yrx7cX"]},"version":1,"coinbase":false,"randipbits":847292520,"coin":"BTC","tag":"18220985608713355389"} + + if ( (txoutjson= cJSON_Parse(retstr)) != 0 ) + { + if ( (sobj= jobj(txoutjson,"scriptPubKey")) != 0 && (array= jarray(&numaddrs,txoutjson,"addresses")) != 0 ) + { + for (j=0; jpubkey,bitcoin_pubkeylen(waddr->pubkey)); + jaddistr(pubkeys,pubkeystr); + printf("pubkeys[%d] <- (%s)\n",j,pubkeystr); + } + } + } + } + free_json(txoutjson); + } + free(retstr); + } + } + else if ( iguana_RTunspentindfind(myinfo,coin,&outpt,coinaddr,spendscript,&spendlen,&satoshis,&height,txid,vout,coin->bundlescount-1,0) == 0 ) { //printf("[%d] unspentind.%d (%s) spendlen.%d %.8f\n",height/coin->chain->bundlesize,unspentind,coinaddr,spendlen,dstr(satoshis)); if ( coinaddr[0] != 0 && (waddr= iguana_waddresssearch(myinfo,&wacct,coinaddr)) != 0 ) diff --git a/iguana/tests/dexgetO b/iguana/tests/dexgetO index c493841b0..23eb89f6e 100755 --- a/iguana/tests/dexgetO +++ b/iguana/tests/dexgetO @@ -1,2 +1,2 @@ #!/bin/bash -curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"gettxout\",\"vout\":1,\"txid\":\"e29562d41d3ad468f579f2b8a9031e23483c639a8434e7c8cda46e6f17bcf1c7\",\"symbol\":\"BTC\"}" +curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"gettxout\",\"vout\":0,\"txid\":\"cad09f4c3e23ef4cde4980cc0e2b296943f22cbaac183a30f86f49f7eccfedfd\",\"symbol\":\"BTC\"}" diff --git a/iguana/tests/dexgetT b/iguana/tests/dexgetT index 3b5689fc0..943f1925c 100755 --- a/iguana/tests/dexgetT +++ b/iguana/tests/dexgetT @@ -1,2 +1,2 @@ #!/bin/bash -curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"gettransaction\",\"txid\":\"aa82ebd1c5bd2a9e19214cbc959df1745378676fddfd6f4903930ac16485c7ae\",\"symbol\":\"BTC\"}" +curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"gettransaction\",\"txid\":\"cad09f4c3e23ef4cde4980cc0e2b296943f22cbaac183a30f86f49f7eccfedfd\",\"symbol\":\"BTC\"}" diff --git a/iguana/tests/dexlistunspent b/iguana/tests/dexlistunspent index 23797979d..c7d033522 100755 --- a/iguana/tests/dexlistunspent +++ b/iguana/tests/dexlistunspent @@ -1,2 +1,2 @@ #!/bin/bash -curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"listunspent\",\"address\":\"bXQu4vm7gJcBvBXDiNU3eyAVrhW44wzCYW\",\"symbol\":\"SHARK\"}" +curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"listunspent\",\"address\":\"1En4tL4drN5qAZDtu1BCC7DThj58yrx7cX\",\"symbol\":\"BTC\"}" diff --git a/iguana/tests/dexvalidate b/iguana/tests/dexvalidate index 66685816d..0136b6fbb 100755 --- a/iguana/tests/dexvalidate +++ b/iguana/tests/dexvalidate @@ -1,2 +1,2 @@ #!/bin/bash -curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"validateaddress\",\"address\":\"1GxuYbLmMVoP4tCzm4s98Q6YU7H963W9kp\",\"symbol\":\"BTC\"}" +curl --url "http://127.0.0.1:7778" --data "{\"agent\":\"dex\",\"method\":\"validateaddress\",\"address\":\"1En4tL4drN5qAZDtu1BCC7DThj58yrx7cX\",\"symbol\":\"BTC\"}"