From ea8aab324b7afa0538a2b5c405e5a82cfb5655e3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 11 Nov 2017 19:27:58 +0200 Subject: [PATCH] Test --- iguana/exchanges/LP_cache.c | 4 ++-- iguana/exchanges/LP_include.h | 2 +- iguana/exchanges/LP_nativeDEX.c | 4 ++-- iguana/exchanges/LP_ordermatch.c | 2 +- iguana/exchanges/LP_socket.c | 3 ++- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/iguana/exchanges/LP_cache.c b/iguana/exchanges/LP_cache.c index e4727a333..d061b0b2a 100644 --- a/iguana/exchanges/LP_cache.c +++ b/iguana/exchanges/LP_cache.c @@ -228,12 +228,12 @@ bits256 LP_merkleroot(struct iguana_info *coin,struct electrum_info *ep,int32_t return(merkleroot); } -int32_t LP_merkleproof(struct iguana_info *coin,struct electrum_info *ep,bits256 txid,int32_t height) +int32_t LP_merkleproof(struct iguana_info *coin,char *coinaddr,struct electrum_info *ep,bits256 txid,int32_t height) { struct LP_transaction *tx=0; cJSON *merkobj,*merkles,*retjson; bits256 roothash,merkleroot; int32_t m,SPV = 0; if ( height < 0 ) return(0); - if ( (tx= LP_transactionfind(coin,txid)) == 0) + if ( (tx= LP_transactionfind(coin,txid)) == 0 && strcmp(coinaddr,coin->smartaddr) == 0 ) { if ( (retjson= electrum_transaction(coin->symbol,ep,&retjson,txid)) != 0 ) free_json(retjson); diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index 5d2283a1e..273625a41 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -428,7 +428,7 @@ int32_t LP_reserved_msg(int32_t priority,char *base,char *rel,bits256 pubkey,cha struct iguana_info *LP_coinfind(char *symbol); int32_t LP_crc32find(int32_t *duplicatep,int32_t ind,uint32_t crc32); char *LP_pricepings(void *ctx,char *myipaddr,int32_t pubsock,char *base,char *rel,double price); -int32_t LP_merkleproof(struct iguana_info *coin,struct electrum_info *ep,bits256 txid,int32_t height); +int32_t LP_merkleproof(struct iguana_info *coin,char *coinaddr,struct electrum_info *ep,bits256 txid,int32_t height); int32_t _LP_utxos_remove(bits256 txid,int32_t vout); int32_t LP_utxos_remove(bits256 txid,int32_t vout); struct LP_transaction *LP_transactionadd(struct iguana_info *coin,bits256 txid,int32_t height,int32_t numvouts,int32_t numvins); diff --git a/iguana/exchanges/LP_nativeDEX.c b/iguana/exchanges/LP_nativeDEX.c index 4d25a76aa..e536875e8 100644 --- a/iguana/exchanges/LP_nativeDEX.c +++ b/iguana/exchanges/LP_nativeDEX.c @@ -527,7 +527,7 @@ void LP_coinsloop(void *_coins) if ( up->SPV == 0 ) { nonz++; - up->SPV = LP_merkleproof(coin,backupep,up->U.txid,up->U.height); + up->SPV = LP_merkleproof(coin,coin->smartaddr,backupep,up->U.txid,up->U.height); if ( up->SPV > 0 ) { if ( (tx= LP_transactionfind(coin,up->U.txid)) != 0 && tx->SPV == 0 ) @@ -544,7 +544,7 @@ void LP_coinsloop(void *_coins) oldht = up->U.height; LP_txheight_check(coin,ap->coinaddr,up); if ( oldht != up->U.height ) - up->SPV = LP_merkleproof(coin,backupep,up->U.txid,up->U.height); + up->SPV = LP_merkleproof(coin,coin->smartaddr,backupep,up->U.txid,up->U.height); if ( up->SPV <= 0 ) up->SPV = -2; else printf("%s %s: corrected SPV.%d\n",coin->symbol,bits256_str(str,up->U.txid),up->SPV); diff --git a/iguana/exchanges/LP_ordermatch.c b/iguana/exchanges/LP_ordermatch.c index e034a5de4..617a7af3f 100644 --- a/iguana/exchanges/LP_ordermatch.c +++ b/iguana/exchanges/LP_ordermatch.c @@ -647,7 +647,7 @@ int32_t LP_validSPV(char *symbol,char *coinaddr,bits256 txid,int32_t vout) return(-1); if ( (backupep= ep->prev) == 0 ) backupep = ep; - up->SPV = LP_merkleproof(coin,backupep,up->U.txid,up->U.height); + up->SPV = LP_merkleproof(coin,coinaddr,backupep,up->U.txid,up->U.height); if ( up->SPV <= 0 ) return(-1); } diff --git a/iguana/exchanges/LP_socket.c b/iguana/exchanges/LP_socket.c index 20357071d..e9ba0388b 100644 --- a/iguana/exchanges/LP_socket.c +++ b/iguana/exchanges/LP_socket.c @@ -329,7 +329,8 @@ int32_t electrum_process_array(struct iguana_info *coin,struct electrum_info *ep tx->height = ht; if ( ep != 0 && coin != 0 && tx->SPV == 0 ) { - tx->SPV = LP_merkleproof(coin,ep,txid,tx->height); + if ( strcmp(coinaddr,coin->smartaddr) == 0 ) + tx->SPV = LP_merkleproof(coin,coin->smartaddr,ep,txid,tx->height); //printf("%s %s >>>>>>>>>> set %s <- height %d\n",coin->symbol,coinaddr,bits256_str(str,txid),tx->height); } }