|
|
@ -708,8 +708,6 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, |
|
|
|
} |
|
|
|
return(retval); |
|
|
|
} |
|
|
|
if ( bits256_cmp(G.LP_mypub25519,Q.srchash) == 0 && bits256_cmp(G.LP_mypub25519,Q.desthash) != 0 ) |
|
|
|
{ |
|
|
|
if ( (coin= LP_coinfind(Q.srccoin)) == 0 || (price= LP_myprice(&bid,&ask,Q.srccoin,Q.destcoin)) <= SMALLVAL || ask <= SMALLVAL ) |
|
|
|
{ |
|
|
|
printf("this node has no price for %s/%s\n",Q.srccoin,Q.destcoin); |
|
|
@ -726,21 +724,11 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, |
|
|
|
return(retval); |
|
|
|
} |
|
|
|
price = ask; |
|
|
|
/*if ( coin->electrum != 0 )
|
|
|
|
{ |
|
|
|
printf("electrum can only be for alice\n"); |
|
|
|
return(retval); |
|
|
|
}*/ |
|
|
|
if ( LP_aliceonly(Q.srccoin) > 0 ) |
|
|
|
{ |
|
|
|
printf("{\"error\":\"GAME can only be alice coin\"}\n"); |
|
|
|
return(retval); |
|
|
|
} |
|
|
|
if ( strcmp(Q.coinaddr,coin->smartaddr) != 0 ) |
|
|
|
{ |
|
|
|
printf("bob is patching Q.coinaddr %s mismatch != %s\n",Q.coinaddr,coin->smartaddr); |
|
|
|
strcpy(Q.coinaddr,coin->smartaddr); |
|
|
|
} |
|
|
|
autxo = &A; |
|
|
|
butxo = &B; |
|
|
|
memset(autxo,0,sizeof(*autxo)); |
|
|
@ -774,6 +762,9 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, |
|
|
|
LP_listunspent_both(Q.srccoin,Q.coinaddr,0); |
|
|
|
if ( (butxo= LP_address_utxopair(1,utxos,max,LP_coinfind(Q.srccoin),Q.coinaddr,Q.txfee,dstr(Q.destsatoshis),price,Q.desttxfee)) != 0 ) |
|
|
|
{ |
|
|
|
strcpy(Q.gui,G.gui); |
|
|
|
strcpy(Q.coinaddr,coin->smartaddr); |
|
|
|
Q.srchash = G.LP_mypub25519; |
|
|
|
Q.txid = butxo->payment.txid; |
|
|
|
Q.vout = butxo->payment.vout; |
|
|
|
Q.txid2 = butxo->deposit.txid; |
|
|
@ -789,7 +780,15 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, |
|
|
|
} |
|
|
|
else // "connect"
|
|
|
|
{ |
|
|
|
butxo = LP_utxopairfind(1,Q.txid,Q.vout,Q.txid2,Q.vout2); |
|
|
|
if ( bits256_cmp(G.LP_mypub25519,Q.srchash) == 0 && bits256_cmp(G.LP_mypub25519,Q.desthash) != 0 ) |
|
|
|
{ |
|
|
|
butxo = LP_utxopairfind(1,Q.txid,Q.vout,Q.txid2,Q.vout2); // better work!
|
|
|
|
} else return(retval); |
|
|
|
} |
|
|
|
if ( strcmp(Q.coinaddr,coin->smartaddr) != 0 ) |
|
|
|
{ |
|
|
|
printf("bob is patching Q.coinaddr %s mismatch != %s\n",Q.coinaddr,coin->smartaddr); |
|
|
|
strcpy(Q.coinaddr,coin->smartaddr); |
|
|
|
} |
|
|
|
char str[65],str2[65]; printf("butxo.%p (%s %s) TRADECOMMAND.(%s)\n",butxo,butxo!=0?bits256_str(str,butxo->payment.txid):"",butxo!=0?bits256_str(str2,butxo->deposit.txid):"",jprint(argjson,0)); |
|
|
|
if ( butxo == 0 || bits256_nonz(butxo->payment.txid) == 0 || bits256_nonz(butxo->deposit.txid) == 0 || butxo->payment.vout < 0 || butxo->deposit.vout < 0 ) |
|
|
@ -851,7 +850,6 @@ int32_t LP_tradecommand(void *ctx,char *myipaddr,int32_t pubsock,cJSON *argjson, |
|
|
|
} |
|
|
|
//LP_butxo_swapfields_set(butxo);
|
|
|
|
} |
|
|
|
} |
|
|
|
return(retval); |
|
|
|
} |
|
|
|
|
|
|
|