diff --git a/iguana/exchanges/LP_utxos.c b/iguana/exchanges/LP_utxos.c index 91027f338..bf159a018 100644 --- a/iguana/exchanges/LP_utxos.c +++ b/iguana/exchanges/LP_utxos.c @@ -251,15 +251,16 @@ cJSON *LP_utxojson(struct LP_utxoinfo *utxo) char *LP_utxos(int32_t iambob,struct LP_peerinfo *mypeer,char *symbol,int32_t lastn) { - int32_t i,firsti; struct LP_utxoinfo *utxo,*tmp; cJSON *utxosjson = cJSON_CreateArray(); + int32_t i,firsti,n; struct LP_utxoinfo *utxo,*tmp; cJSON *utxosjson = cJSON_CreateArray(); if ( symbol != 0 && symbol[0] != 0 ) { i = 0; + n = mypeer != 0 ? mypeer->numutxos : 0; if ( lastn <= 0 ) lastn = LP_PROPAGATION_SLACK * 2; - if ( lastn >= mypeer->numutxos ) + if ( lastn >= n ) firsti = -1; - else firsti = (mypeer->numutxos - lastn); + else firsti = (n - lastn); HASH_ITER(hh,LP_utxoinfos[iambob],utxo,tmp) { if ( i++ < firsti )