|
@ -181,64 +181,6 @@ char *LP_quotereceived(cJSON *argjson) |
|
|
} else return(clonestr("{\"error\":\"nullptr\"}")); |
|
|
} else return(clonestr("{\"error\":\"nullptr\"}")); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void LP_smartutxos_push(struct iguana_info *coin) |
|
|
|
|
|
{ |
|
|
|
|
|
struct LP_peerinfo *peer,*tmp; uint64_t value; bits256 zero,txid; int32_t i,vout,height,n; char *retstr; cJSON *array,*item,*req; |
|
|
|
|
|
if ( coin->smartaddr[0] == 0 ) |
|
|
|
|
|
return; |
|
|
|
|
|
if ( (array= LP_address_utxos(coin,coin->smartaddr,1)) != 0 ) |
|
|
|
|
|
{ |
|
|
|
|
|
memset(zero.bytes,0,sizeof(zero)); |
|
|
|
|
|
if ( (n= cJSON_GetArraySize(array)) > 0 ) |
|
|
|
|
|
{ |
|
|
|
|
|
//printf("PUSH %s %s\n",coin->symbol,coin->smartaddr);
|
|
|
|
|
|
for (i=0; i<n; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
item = jitem(array,i); |
|
|
|
|
|
txid = jbits256(item,"tx_hash"); |
|
|
|
|
|
vout = jint(item,"tx_pos"); |
|
|
|
|
|
value = j64bits(item,"value"); |
|
|
|
|
|
height = jint(item,"height"); |
|
|
|
|
|
if ( 0 && (rand() % 100) == 0 && IAMLP == 0 ) |
|
|
|
|
|
{ |
|
|
|
|
|
HASH_ITER(hh,LP_peerinfos,peer,tmp) |
|
|
|
|
|
{ |
|
|
|
|
|
if ( (retstr= issue_LP_uitem(peer->ipaddr,peer->port,coin->symbol,coin->smartaddr,txid,vout,height,value)) != 0 ) |
|
|
|
|
|
free(retstr); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
req = cJSON_CreateObject(); |
|
|
|
|
|
jaddstr(req,"method","uitem"); |
|
|
|
|
|
jaddstr(req,"coin",coin->symbol); |
|
|
|
|
|
jaddstr(req,"coinaddr",coin->smartaddr); |
|
|
|
|
|
jaddbits256(req,"txid",txid); |
|
|
|
|
|
jaddnum(req,"vout",vout); |
|
|
|
|
|
jaddnum(req,"ht",height); |
|
|
|
|
|
jadd64bits(req,"value",value); |
|
|
|
|
|
//printf("ADDR_UNSPENTS[] <- %s\n",jprint(req,0));
|
|
|
|
|
|
LP_reserved_msg("","",zero,jprint(req,1)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
free_json(array); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
char *LP_uitem_recv(cJSON *argjson) |
|
|
|
|
|
{ |
|
|
|
|
|
bits256 txid; int32_t vout,height; uint64_t value; char *coinaddr,*symbol; |
|
|
|
|
|
txid = jbits256(argjson,"txid"); |
|
|
|
|
|
vout = jint(argjson,"vout"); |
|
|
|
|
|
height = jint(argjson,"ht"); |
|
|
|
|
|
value = j64bits(argjson,"value"); |
|
|
|
|
|
coinaddr = jstr(argjson,"coinaddr"); |
|
|
|
|
|
if ( (symbol= jstr(argjson,"coin")) != 0 && coinaddr != 0 ) |
|
|
|
|
|
{ |
|
|
|
|
|
//char str[65]; printf("uitem %s %s %s/v%d %.8f ht.%d\n",coin,coinaddr,bits256_str(str,txid),vout,dstr(value),height);
|
|
|
|
|
|
LP_address_utxoadd(LP_coinfind(symbol),coinaddr,txid,vout,value,height,-1); |
|
|
|
|
|
} |
|
|
|
|
|
return(clonestr("{\"result\":\"success\"}")); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void LP_postutxos(char *symbol,char *coinaddr) |
|
|
void LP_postutxos(char *symbol,char *coinaddr) |
|
|
{ |
|
|
{ |
|
|
bits256 zero; struct iguana_info *coin; cJSON *array,*reqjson = cJSON_CreateObject(); |
|
|
bits256 zero; struct iguana_info *coin; cJSON *array,*reqjson = cJSON_CreateObject(); |
|
@ -457,6 +399,65 @@ char *LP_notify_recv(cJSON *argjson) |
|
|
return(clonestr("{\"result\":\"success\",\"notify\":\"received\"}")); |
|
|
return(clonestr("{\"result\":\"success\",\"notify\":\"received\"}")); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void LP_smartutxos_push(struct iguana_info *coin) |
|
|
|
|
|
{ |
|
|
|
|
|
struct LP_peerinfo *peer,*tmp; uint64_t value; bits256 zero,txid; int32_t i,vout,height,n; char *retstr; cJSON *array,*item,*req; |
|
|
|
|
|
if ( coin->smartaddr[0] == 0 ) |
|
|
|
|
|
return; |
|
|
|
|
|
LP_notify_pubkeys(coin->ctx,LP_mypubsock); |
|
|
|
|
|
if ( (array= LP_address_utxos(coin,coin->smartaddr,1)) != 0 ) |
|
|
|
|
|
{ |
|
|
|
|
|
memset(zero.bytes,0,sizeof(zero)); |
|
|
|
|
|
if ( (n= cJSON_GetArraySize(array)) > 0 ) |
|
|
|
|
|
{ |
|
|
|
|
|
//printf("PUSH %s %s\n",coin->symbol,coin->smartaddr);
|
|
|
|
|
|
for (i=0; i<n; i++) |
|
|
|
|
|
{ |
|
|
|
|
|
item = jitem(array,i); |
|
|
|
|
|
txid = jbits256(item,"tx_hash"); |
|
|
|
|
|
vout = jint(item,"tx_pos"); |
|
|
|
|
|
value = j64bits(item,"value"); |
|
|
|
|
|
height = jint(item,"height"); |
|
|
|
|
|
if ( 0 && (rand() % 100) == 0 && IAMLP == 0 ) |
|
|
|
|
|
{ |
|
|
|
|
|
HASH_ITER(hh,LP_peerinfos,peer,tmp) |
|
|
|
|
|
{ |
|
|
|
|
|
if ( (retstr= issue_LP_uitem(peer->ipaddr,peer->port,coin->symbol,coin->smartaddr,txid,vout,height,value)) != 0 ) |
|
|
|
|
|
free(retstr); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
req = cJSON_CreateObject(); |
|
|
|
|
|
jaddstr(req,"method","uitem"); |
|
|
|
|
|
jaddstr(req,"coin",coin->symbol); |
|
|
|
|
|
jaddstr(req,"coinaddr",coin->smartaddr); |
|
|
|
|
|
jaddbits256(req,"txid",txid); |
|
|
|
|
|
jaddnum(req,"vout",vout); |
|
|
|
|
|
jaddnum(req,"ht",height); |
|
|
|
|
|
jadd64bits(req,"value",value); |
|
|
|
|
|
//printf("ADDR_UNSPENTS[] <- %s\n",jprint(req,0));
|
|
|
|
|
|
LP_reserved_msg("","",zero,jprint(req,1)); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
free_json(array); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
char *LP_uitem_recv(cJSON *argjson) |
|
|
|
|
|
{ |
|
|
|
|
|
bits256 txid; int32_t vout,height; uint64_t value; char *coinaddr,*symbol; |
|
|
|
|
|
txid = jbits256(argjson,"txid"); |
|
|
|
|
|
vout = jint(argjson,"vout"); |
|
|
|
|
|
height = jint(argjson,"ht"); |
|
|
|
|
|
value = j64bits(argjson,"value"); |
|
|
|
|
|
coinaddr = jstr(argjson,"coinaddr"); |
|
|
|
|
|
if ( (symbol= jstr(argjson,"coin")) != 0 && coinaddr != 0 ) |
|
|
|
|
|
{ |
|
|
|
|
|
//char str[65]; printf("uitem %s %s %s/v%d %.8f ht.%d\n",coin,coinaddr,bits256_str(str,txid),vout,dstr(value),height);
|
|
|
|
|
|
LP_address_utxoadd(LP_coinfind(symbol),coinaddr,txid,vout,value,height,-1); |
|
|
|
|
|
} |
|
|
|
|
|
return(clonestr("{\"result\":\"success\"}")); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
void LP_listunspent_query(char *symbol,char *coinaddr) |
|
|
void LP_listunspent_query(char *symbol,char *coinaddr) |
|
|
{ |
|
|
{ |
|
|
bits256 zero; cJSON *reqjson = cJSON_CreateObject(); |
|
|
bits256 zero; cJSON *reqjson = cJSON_CreateObject(); |
|
|