Browse Source

Merge pull request #110 from artemii235/etomic

#104 #108. Add txChain to tradestatus. Do not wait for bob deposit in case of error.
pass-iguana-arg
Artem Pikulin 7 years ago
committed by GitHub
parent
commit
81af671fb3
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 40
      iguana/exchanges/LP_etomic.c
  2. 17
      iguana/exchanges/LP_include.h
  3. 6
      iguana/exchanges/LP_mmjson.c
  4. 139
      iguana/exchanges/LP_remember.c
  5. 34
      iguana/exchanges/LP_swap.c

40
iguana/exchanges/LP_etomic.c

@ -200,11 +200,11 @@ uint8_t LP_etomic_verify_alice_payment(struct basilisk_swap *swap, char *txId)
char *LP_etomicalice_reclaims_payment(struct LP_swap_remember *swap)
{
if (waitForConfirmation(swap->alicePaymentEthTx) < 0) {
printf("Alice ETH payment %s is not found, can't reclaim\n", swap->alicePaymentEthTx);
if (waitForConfirmation(swap->eth_tx_ids[BASILISK_ALICEPAYMENT]) < 0) {
printf("Alice ETH payment %s is not found, can't reclaim\n", swap->eth_tx_ids[BASILISK_ALICEPAYMENT]);
return NULL;
}
EthTxReceipt receipt = getEthTxReceipt(swap->alicePaymentEthTx);
EthTxReceipt receipt = getEthTxReceipt(swap->eth_tx_ids[BASILISK_ALICEPAYMENT]);
if (strcmp(receipt.status, "0x1") != 0) {
printf("Alice payment receipt status failed, can't reclaim\n");
return NULL;
@ -252,11 +252,11 @@ char *LP_etomicalice_reclaims_payment(struct LP_swap_remember *swap)
char *LP_etomicbob_spends_alice_payment(struct LP_swap_remember *swap)
{
if (waitForConfirmation(swap->alicePaymentEthTx) < 0) {
printf("Alice ETH payment %s is not found, can't spend\n", swap->alicePaymentEthTx);
if (waitForConfirmation(swap->eth_tx_ids[BASILISK_ALICEPAYMENT]) < 0) {
printf("Alice ETH payment %s is not found, can't spend\n", swap->eth_tx_ids[BASILISK_ALICEPAYMENT]);
return NULL;
}
EthTxReceipt receipt = getEthTxReceipt(swap->alicePaymentEthTx);
EthTxReceipt receipt = getEthTxReceipt(swap->eth_tx_ids[BASILISK_ALICEPAYMENT]);
if (strcmp(receipt.status, "0x1") != 0) {
printf("Alice payment receipt status failed, can't spend\n");
return NULL;
@ -408,8 +408,8 @@ uint8_t LP_etomic_verify_bob_deposit(struct basilisk_swap *swap, char *txId)
char *LP_etomicbob_refunds_deposit(struct LP_swap_remember *swap)
{
if (waitForConfirmation(swap->bobDepositEthTx) < 0) {
printf("Bob deposit %s is not found, can't refund\n", swap->bobDepositEthTx);
if (waitForConfirmation(swap->eth_tx_ids[BASILISK_BOBDEPOSIT]) < 0) {
printf("Bob deposit %s is not found, can't refund\n", swap->eth_tx_ids[BASILISK_BOBDEPOSIT]);
return NULL;
}
BobRefundsDepositInput input;
@ -423,9 +423,9 @@ char *LP_etomicbob_refunds_deposit(struct LP_swap_remember *swap)
bobcoin = LP_coinfind(swap->src);
privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr);
EthTxReceipt receipt = getEthTxReceipt(swap->bobDepositEthTx);
EthTxReceipt receipt = getEthTxReceipt(swap->eth_tx_ids[BASILISK_BOBDEPOSIT]);
if (strcmp(receipt.status, "0x1") != 0) {
printf("Bob deposit %s receipt status failed, can't refund\n", swap->bobDepositEthTx);
printf("Bob deposit %s receipt status failed, can't refund\n", swap->eth_tx_ids[BASILISK_BOBDEPOSIT]);
return NULL;
}
uint8arrayToHex(input.depositId, swap->txids[BASILISK_BOBDEPOSIT].bytes, 32);
@ -562,8 +562,8 @@ uint8_t LP_etomic_verify_bob_payment(struct basilisk_swap *swap, char *txId)
char *LP_etomicbob_reclaims_payment(struct LP_swap_remember *swap)
{
if (waitForConfirmation(swap->bobPaymentEthTx) < 0) {
printf("Bob payment %s is not found, can't reclaim\n", swap->bobPaymentEthTx);
if (waitForConfirmation(swap->eth_tx_ids[BASILISK_BOBPAYMENT]) < 0) {
printf("Bob payment %s is not found, can't reclaim\n", swap->eth_tx_ids[BASILISK_BOBPAYMENT]);
return NULL;
}
BobReclaimsBobPaymentInput input;
@ -577,7 +577,7 @@ char *LP_etomicbob_reclaims_payment(struct LP_swap_remember *swap)
bobcoin = LP_coinfind(swap->src);
privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr);
EthTxReceipt receipt = getEthTxReceipt(swap->bobPaymentEthTx);
EthTxReceipt receipt = getEthTxReceipt(swap->eth_tx_ids[BASILISK_BOBPAYMENT]);
if (strcmp(receipt.status, "0x1") != 0) {
printf("Bob payment receipt status failed, can't reclaim\n");
return NULL;
@ -607,8 +607,8 @@ char *LP_etomicbob_reclaims_payment(struct LP_swap_remember *swap)
char *LP_etomicalice_spends_bob_payment(struct LP_swap_remember *swap)
{
if (waitForConfirmation(swap->bobPaymentEthTx) < 0) {
printf("Bob payment %s is not found, can't spend\n", swap->bobPaymentEthTx);
if (waitForConfirmation(swap->eth_tx_ids[BASILISK_BOBPAYMENT]) < 0) {
printf("Bob payment %s is not found, can't spend\n", swap->eth_tx_ids[BASILISK_BOBPAYMENT]);
return NULL;
}
AliceSpendsBobPaymentInput input;
@ -616,9 +616,9 @@ char *LP_etomicalice_spends_bob_payment(struct LP_swap_remember *swap)
memset(&txData,0,sizeof(txData));
memset(&input,0,sizeof(input));
EthTxReceipt receipt = getEthTxReceipt(swap->bobPaymentEthTx);
EthTxReceipt receipt = getEthTxReceipt(swap->eth_tx_ids[BASILISK_BOBPAYMENT]);
if (strcmp(receipt.status, "0x1") != 0) {
printf("Bob payment %s receipt status failed, can't spend\n", swap->bobPaymentEthTx);
printf("Bob payment %s receipt status failed, can't spend\n", swap->eth_tx_ids[BASILISK_BOBPAYMENT]);
return NULL;
}
struct iguana_info *ecoin, *bobcoin;
@ -658,8 +658,8 @@ char *LP_etomicalice_spends_bob_payment(struct LP_swap_remember *swap)
char *LP_etomicalice_claims_bob_deposit(struct LP_swap_remember *swap)
{
if (waitForConfirmation(swap->bobDepositEthTx) < 0) {
printf("Bob deposit %s is not found, can't claim\n", swap->bobDepositEthTx);
if (waitForConfirmation(swap->eth_tx_ids[BASILISK_BOBDEPOSIT]) < 0) {
printf("Bob deposit %s is not found, can't claim\n", swap->eth_tx_ids[BASILISK_BOBDEPOSIT]);
return NULL;
}
AliceClaimsBobDepositInput input;
@ -667,7 +667,7 @@ char *LP_etomicalice_claims_bob_deposit(struct LP_swap_remember *swap)
memset(&txData,0,sizeof(txData));
memset(&input,0,sizeof(input));
EthTxReceipt receipt = getEthTxReceipt(swap->bobDepositEthTx);
EthTxReceipt receipt = getEthTxReceipt(swap->eth_tx_ids[BASILISK_BOBDEPOSIT]);
if (strcmp(receipt.status, "0x1") != 0) {
printf("Bob deposit receipt status failed, can't claim\n");
return NULL;

17
iguana/exchanges/LP_include.h

@ -256,19 +256,19 @@ struct basilisk_swapinfo
uint8_t userdata_bobrefund[256],userdata_bobrefundlen;
};
#define BASILISK_ALICESPEND 0
#define BASILISK_BOBSPEND 1
#define BASILISK_BOBPAYMENT 2
#define BASILISK_MYFEE 0
#define BASILISK_OTHERFEE 1
#define BASILISK_BOBDEPOSIT 2
#define BASILISK_ALICEPAYMENT 3
#define BASILISK_BOBDEPOSIT 4
#define BASILISK_OTHERFEE 5
#define BASILISK_MYFEE 6
#define BASILISK_BOBPAYMENT 4
#define BASILISK_ALICESPEND 5
#define BASILISK_BOBSPEND 6
#define BASILISK_BOBREFUND 7
#define BASILISK_BOBRECLAIM 8
#define BASILISK_ALICERECLAIM 9
#define BASILISK_ALICECLAIM 10
//0, 0, 1, 1, 1, 0, 1, 1, 1, 0, 0
static char *txnames[] = { "alicespend", "bobspend", "bobpayment", "alicepayment", "bobdeposit", "otherfee", "myfee", "bobrefund", "bobreclaim", "alicereclaim", "aliceclaim" };
static char *txnames[] = { "myfee", "otherfee", "bobdeposit", "alicepayment", "bobpayment", "alicespend", "bobspend", "bobrefund", "bobreclaim", "alicereclaim", "aliceclaim" };
struct LP_swap_remember
{
@ -279,7 +279,8 @@ struct LP_swap_remember
int32_t iambob,finishedflag,origfinishedflag,Predeemlen,Dredeemlen,sentflags[sizeof(txnames)/sizeof(*txnames)];
uint8_t secretAm[20],secretAm256[32],secretBn[20],secretBn256[32],Predeemscript[1024],Dredeemscript[1024],pubkey33[33],other33[33];
char uuidstr[65],Agui[65],Bgui[65],gui[65],src[65],dest[65],bobtomic[128],alicetomic[128],etomicsrc[65],etomicdest[65],destaddr[64],Adestaddr[64],Sdestaddr[64],alicepaymentaddr[64],bobpaymentaddr[64],bobdepositaddr[64],alicecoin[65],bobcoin[65],*txbytes[sizeof(txnames)/sizeof(*txnames)];
char bobDepositEthTx[75],bobPaymentEthTx[75],aliceFeeEthTx[75],alicePaymentEthTx[75],bobPaymentSpentEth[75],alicePaymentSpentEth[75],bobDepositSpentEth[75];
char eth_tx_ids[sizeof(txnames)/sizeof(*txnames)][75];
int64_t eth_values[sizeof(txnames)/sizeof(*txnames)];
};
struct LP_outpoint

6
iguana/exchanges/LP_mmjson.c

@ -259,15 +259,11 @@ int32_t MMJSON_decodeitem(cJSON *lineobj,uint8_t *linebuf,int32_t i,int32_t len,
arbstr[j++] = c;
}
arbstr[j] = 0;
#ifndef NOTETOMIC
if (strcmp(fieldstr, "eth_info") == 0) {
if (strcmp(fieldstr, "txChain") == 0) {
cJSON_AddItemToObject(lineobj, fieldstr, cJSON_Parse(arbstr));
} else {
#endif
jaddstr(lineobj, fieldstr, arbstr);
#ifndef NOTETOMIC
}
#endif
break;
default:
if ( valind < MMJSON_BOUNDARY )

139
iguana/exchanges/LP_remember.c

@ -13,10 +13,33 @@
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/
#include "LP_include.h"
#include "../../includes/cJSON.h"
//
// LP_remember.c
// marketmaker
//
char *coin_name_by_tx_index(struct LP_swap_remember *rswap, int32_t tx_index)
{
switch (tx_index) {
case BASILISK_MYFEE:
case BASILISK_OTHERFEE:
case BASILISK_ALICEPAYMENT:
case BASILISK_ALICERECLAIM:
case BASILISK_BOBSPEND:
return rswap->dest;
case BASILISK_BOBDEPOSIT:
case BASILISK_BOBPAYMENT:
case BASILISK_BOBRECLAIM:
case BASILISK_BOBREFUND:
case BASILISK_ALICESPEND:
case BASILISK_ALICECLAIM:
return rswap->src;
default:
return 0;
}
}
void basilisk_dontforget_userdata(char *userdataname,FILE *fp,uint8_t *script,int32_t scriptlen)
{
int32_t i; char scriptstr[513];
@ -70,6 +93,7 @@ void basilisk_dontforget(struct basilisk_swap *swap,struct basilisk_rawtx *rawtx
fprintf(fp,",\"bobtomic\":\"%s\"",swap->I.bobtomic);
if ( swap->I.etomicsrc[0] != 0 )
fprintf(fp,",\"etomicsrc\":\"%s\"",swap->I.etomicsrc);
#ifndef NOTETOMIC
if (swap->myfee.I.ethTxid[0] != 0) {
fprintf(fp,",\"aliceFeeEthTx\":\"%s\"", swap->myfee.I.ethTxid);
}
@ -88,7 +112,7 @@ void basilisk_dontforget(struct basilisk_swap *swap,struct basilisk_rawtx *rawtx
fprintf(fp,",\"aliceRealSat\":\"%" PRId64 "\"", swap->I.alicerealsat);
fprintf(fp,",\"bobRealSat\":\"%" PRId64 "\"", swap->I.bobrealsat);
#endif
fprintf(fp,",\"alicecoin\":\"%s\"",swap->I.alicestr);
if ( swap->I.alicetomic[0] != 0 )
fprintf(fp,",\"alicetomic\":\"%s\"",swap->I.alicetomic);
@ -681,13 +705,31 @@ cJSON *LP_swap_json(struct LP_swap_remember *rswap)
jaddnum(item,"alicetxfee",dstr(rswap->Atxfee));
jadd64bits(item,"aliceid",rswap->aliceid);
array = cJSON_CreateArray();
cJSON *tx_chain = cJSON_CreateArray();
for (i=0; i<sizeof(txnames)/sizeof(*txnames); i++)
{
if ( rswap->sentflags[i] != 0 )
jaddistr(array,txnames[i]);
if ( rswap->sentflags[i] != 0 ) {
jaddistr(array, txnames[i]);
cJSON *tx = cJSON_CreateObject();
jaddstr(tx, "stage", txnames[i]);
jaddstr(tx, "coin", coin_name_by_tx_index(rswap, i));
#ifndef NOTETOMIC
if (LP_etomic_is_empty_tx_id(rswap->eth_tx_ids[i]) == 0) {
jaddstr(tx, "txid", rswap->eth_tx_ids[i]);
jaddnum(tx, "amount", dstr(rswap->eth_values[i]));
} else {
#endif
jaddbits256(tx, "txid", rswap->txids[i]);
jaddnum(tx, "amount", dstr(rswap->values[i]));
#ifndef NOTETOMIC
}
#endif
jaddi(tx_chain, tx);
}
if ( rswap->txbytes[i] != 0 )
free(rswap->txbytes[i]), rswap->txbytes[i] = 0;
}
jadd(item, "txChain", tx_chain);
jadd(item,"sentflags",array);
array = cJSON_CreateArray();
for (i=0; i<sizeof(txnames)/sizeof(*txnames); i++)
@ -707,56 +749,6 @@ cJSON *LP_swap_json(struct LP_swap_remember *rswap)
jaddbits256(item,"Apaymentspent",rswap->Apaymentspent);
jaddbits256(item,"depositspent",rswap->depositspent);
jaddbits256(item,"alicedexfee",rswap->iambob == 0 ? rswap->txids[BASILISK_MYFEE] : rswap->txids[BASILISK_OTHERFEE]);
#ifndef NOTETOMIC
if ( rswap->bobtomic[0] != 0 || rswap->alicetomic[0] != 0) {
cJSON *eth_info = cJSON_CreateObject();
if (rswap->alicetomic[0] != 0) {
cJSON *a_fee = cJSON_CreateObject();
jaddstr(a_fee, "txid", rswap->aliceFeeEthTx);
jaddnum(a_fee, "amount", dstr(LP_DEXFEE(rswap->alicerealsat)));
cJSON_AddItemToObject(eth_info, "alicefee", a_fee);
cJSON *a_payment = cJSON_CreateObject();
jaddstr(a_payment, "txid", rswap->alicePaymentEthTx);
jaddnum(a_payment, "amount", dstr(rswap->alicerealsat));
cJSON_AddItemToObject(eth_info, "alicepayment", a_payment);
if (rswap->alicePaymentSpentEth[0] != 0) {
cJSON *a_payment_spent = cJSON_CreateObject();
jaddstr(a_payment_spent, "txid", rswap->alicePaymentSpentEth);
jaddnum(a_payment_spent, "amount", dstr(rswap->alicerealsat));
cJSON_AddItemToObject(eth_info, "alicepaymentspent", a_payment_spent);
}
}
if (rswap->bobtomic[0] != 0) {
cJSON *b_deposit = cJSON_CreateObject();
jaddstr(b_deposit, "txid", rswap->bobDepositEthTx);
jaddnum(b_deposit, "amount", dstr(LP_DEPOSITSATOSHIS(rswap->bobrealsat)));
cJSON_AddItemToObject(eth_info, "bobdeposit", b_deposit);
cJSON *b_payment = cJSON_CreateObject();
jaddstr(b_payment, "txid", rswap->bobPaymentEthTx);
jaddnum(b_payment, "amount", dstr(rswap->bobrealsat));
cJSON_AddItemToObject(eth_info, "bobpayment", b_payment);
if (rswap->bobDepositSpentEth[0] != 0) {
cJSON *b_deposit_spent = cJSON_CreateObject();
jaddstr(b_deposit_spent, "txid", rswap->bobDepositSpentEth);
jaddnum(b_deposit_spent, "amount", dstr(LP_DEPOSITSATOSHIS(rswap->bobrealsat)));
cJSON_AddItemToObject(eth_info, "bobdepositspent", b_deposit_spent);
}
if (rswap->bobPaymentSpentEth[0] != 0) {
cJSON *b_payment_spent = cJSON_CreateObject();
jaddstr(b_payment_spent, "txid", rswap->bobPaymentSpentEth);
jaddnum(b_payment_spent, "amount", dstr(rswap->bobrealsat));
cJSON_AddItemToObject(eth_info, "bobpaymentspent", b_payment_spent);
}
}
cJSON_AddItemToObject(item, "eth_info", eth_info);
}
#endif
return(item);
}
@ -977,20 +969,32 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap,int32_t forceflag)
strcpy(rswap->etomicdest,jstr(txobj,"etomicdest"));
}
rswap->bobrealsat = jint(txobj, "bobRealSat");
rswap->alicerealsat = jint(txobj, "aliceRealSat");
if (jstr(txobj,"aliceFeeEthTx") != 0) {
strcpy(rswap->aliceFeeEthTx, jstr(txobj,"aliceFeeEthTx"));
if (rswap->iambob == 0) {
strcpy(rswap->eth_tx_ids[BASILISK_MYFEE], jstr(txobj, "aliceFeeEthTx"));
rswap->eth_values[BASILISK_MYFEE] = LP_DEXFEE(rswap->alicerealsat);
} else {
strcpy(rswap->eth_tx_ids[BASILISK_OTHERFEE], jstr(txobj, "aliceFeeEthTx"));
rswap->eth_values[BASILISK_OTHERFEE] = LP_DEXFEE(rswap->alicerealsat);
}
}
if (jstr(txobj,"bobDepositEthTx") != 0) {
strcpy(rswap->bobDepositEthTx, jstr(txobj,"bobDepositEthTx"));
strcpy(rswap->eth_tx_ids[BASILISK_BOBDEPOSIT], jstr(txobj,"bobDepositEthTx"));
rswap->eth_values[BASILISK_BOBDEPOSIT] = LP_DEPOSITSATOSHIS(rswap->bobrealsat);
}
if (jstr(txobj,"bobPaymentEthTx") != 0) {
strcpy(rswap->bobPaymentEthTx, jstr(txobj,"bobPaymentEthTx"));
strcpy(rswap->eth_tx_ids[BASILISK_BOBPAYMENT], jstr(txobj,"bobPaymentEthTx"));
rswap->eth_values[BASILISK_BOBPAYMENT] = rswap->bobrealsat;
}
if (jstr(txobj,"alicePaymentEthTx") != 0) {
strcpy(rswap->alicePaymentEthTx, jstr(txobj,"alicePaymentEthTx"));
strcpy(rswap->eth_tx_ids[BASILISK_ALICEPAYMENT], jstr(txobj,"alicePaymentEthTx"));
rswap->eth_values[BASILISK_ALICEPAYMENT] = rswap->alicerealsat;
}
if (jstr(txobj,"bobtomic") != 0) {
@ -1001,9 +1005,6 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap,int32_t forceflag)
strcpy(rswap->alicetomic, jstr(txobj,"alicetomic"));
}
rswap->bobrealsat = jint(txobj, "bobRealSat");
rswap->alicerealsat = jint(txobj, "aliceRealSat");
rswap->txids[i] = txid;
if ( jstr(txobj,"Apayment") != 0 )
safecopy(rswap->alicepaymentaddr,jstr(txobj,"Apayment"),sizeof(rswap->alicepaymentaddr));
@ -1358,7 +1359,8 @@ cJSON *basilisk_remember(int32_t fastflag,int64_t *KMDtotals,int64_t *BTCtotals,
{
char *aliceSpendEthTxId = LP_etomicalice_spends_bob_payment(&rswap);
if (aliceSpendEthTxId != NULL) {
strcpy(rswap.bobPaymentSpentEth, aliceSpendEthTxId);
strcpy(rswap.eth_tx_ids[BASILISK_ALICESPEND], aliceSpendEthTxId);
rswap.eth_values[BASILISK_ALICESPEND] = rswap.bobrealsat;
free(aliceSpendEthTxId);
} else {
printf("Alice spend ETH tx send failed!\n");
@ -1408,7 +1410,8 @@ cJSON *basilisk_remember(int32_t fastflag,int64_t *KMDtotals,int64_t *BTCtotals,
{
char *aliceClaimsEthTxId = LP_etomicalice_claims_bob_deposit(&rswap);
if (aliceClaimsEthTxId != NULL) {
strcpy(rswap.bobDepositSpentEth, aliceClaimsEthTxId);
strcpy(rswap.eth_tx_ids[BASILISK_ALICECLAIM], aliceClaimsEthTxId);
rswap.eth_values[BASILISK_ALICECLAIM] = LP_DEPOSITSATOSHIS(rswap.bobrealsat);
free(aliceClaimsEthTxId);
} else {
printf("Alice Bob deposit claim ETH tx failed!\n");
@ -1442,7 +1445,8 @@ cJSON *basilisk_remember(int32_t fastflag,int64_t *KMDtotals,int64_t *BTCtotals,
{
char *aliceReclaimEthTx = LP_etomicalice_reclaims_payment(&rswap);
if (aliceReclaimEthTx != NULL) {
strcpy(rswap.alicePaymentSpentEth, aliceReclaimEthTx);
strcpy(rswap.eth_tx_ids[BASILISK_ALICERECLAIM], aliceReclaimEthTx);
rswap.eth_values[BASILISK_ALICERECLAIM] = rswap.alicerealsat;
free(aliceReclaimEthTx);
} else {
printf("Alice could not reclaim ETH/ERC20 payment!\n");
@ -1490,7 +1494,8 @@ cJSON *basilisk_remember(int32_t fastflag,int64_t *KMDtotals,int64_t *BTCtotals,
{
char *bobSpendEthTx = LP_etomicbob_spends_alice_payment(&rswap);
if (bobSpendEthTx != NULL) {
strcpy(rswap.alicePaymentSpentEth, bobSpendEthTx);
strcpy(rswap.eth_tx_ids[BASILISK_BOBSPEND], bobSpendEthTx);
rswap.eth_values[BASILISK_BOBSPEND] = rswap.alicerealsat;
free(bobSpendEthTx);
} else {
printf("Bob spends Alice payment ETH tx send failed!\n");
@ -1528,7 +1533,8 @@ cJSON *basilisk_remember(int32_t fastflag,int64_t *KMDtotals,int64_t *BTCtotals,
{
char *bobReclaimEthTx = LP_etomicbob_reclaims_payment(&rswap);
if (bobReclaimEthTx != NULL) {
strcpy(rswap.bobPaymentSpentEth, bobReclaimEthTx);
strcpy(rswap.eth_tx_ids[BASILISK_BOBRECLAIM], bobReclaimEthTx);
rswap.eth_values[BASILISK_BOBRECLAIM] = rswap.bobrealsat;
free(bobReclaimEthTx);
} else {
printf("Bob reclaims payment ETH tx send failed!\n");
@ -1582,7 +1588,8 @@ cJSON *basilisk_remember(int32_t fastflag,int64_t *KMDtotals,int64_t *BTCtotals,
{
char *bobRefundsEthTx = LP_etomicbob_refunds_deposit(&rswap);
if (bobRefundsEthTx != NULL) {
strcpy(rswap.bobDepositSpentEth, bobRefundsEthTx);
strcpy(rswap.eth_tx_ids[BASILISK_BOBREFUND], bobRefundsEthTx);
rswap.eth_values[BASILISK_BOBREFUND] = LP_DEPOSITSATOSHIS(rswap.bobrealsat);
free(bobRefundsEthTx);
} else {
printf("Bob refunds deposit ETH tx send failed!\n");

34
iguana/exchanges/LP_swap.c

@ -876,7 +876,6 @@ void LP_bobloop(void *_swap)
err = -2003, printf("error bobscripts deposit\n");
else
{
uint8_t error = 0;
swap->bobrefund.utxovout = 0;
swap->bobrefund.utxotxid = swap->bobdeposit.I.signedtxid;
basilisk_bobdeposit_refund(swap,swap->I.putduration);
@ -886,33 +885,32 @@ void LP_bobloop(void *_swap)
LP_unavailableset(swap->bobdeposit.utxotxid,swap->bobdeposit.utxovout,(uint32_t)time(NULL)+60,swap->I.otherhash);
if ( LP_waitfor(swap->N.pair,swap,bobwaittimeout,LP_verify_otherfee) < 0 )
{
error = 1;
err = -2004, printf("error waiting for alicefee\n");
}
if ( error == 0 )
if ( err == 0 )
{
if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x200,data,maxlen,&swap->bobdeposit,0x100,0) == 0 )
{
error = 1;
err = -2005, printf("error sending bobdeposit\n");
}
}
LP_unavailableset(swap->bobpayment.utxotxid,swap->bobpayment.utxovout,(uint32_t)time(NULL)+60,swap->I.otherhash);
m = swap->I.bobconfirms;
while ( (n= LP_numconfirms(bobstr,swap->bobdeposit.I.destaddr,swap->bobdeposit.I.signedtxid,0,1)) < m )
{
LP_swap_critical = (uint32_t)time(NULL);
if (err == 0) {
LP_unavailableset(swap->bobpayment.utxotxid,swap->bobpayment.utxovout,(uint32_t)time(NULL)+60,swap->I.otherhash);
char str[65];printf("%d wait for bobdeposit %s numconfs.%d %s %s\n",n,swap->bobdeposit.I.destaddr,m,bobstr,bits256_str(str,swap->bobdeposit.I.signedtxid));
sleep(10);
}
printf("wait for alicepayment\n");
if ( error == 0 && LP_waitfor(swap->N.pair,swap,bobwaittimeout + alicewaittimeout,LP_verify_alicepayment) < 0 )
{
error = 1;
err = -2006, printf("error waiting for alicepayment\n");
m = swap->I.bobconfirms;
while ((n = LP_numconfirms(bobstr, swap->bobdeposit.I.destaddr, swap->bobdeposit.I.signedtxid, 0, 1)) < m) {
LP_swap_critical = (uint32_t) time(NULL);
LP_unavailableset(swap->bobpayment.utxotxid, swap->bobpayment.utxovout, (uint32_t) time(NULL) + 60, swap->I.otherhash);
char str[65];
printf("%d wait for bobdeposit %s numconfs.%d %s %s\n", n, swap->bobdeposit.I.destaddr, m, bobstr, bits256_str(str, swap->bobdeposit.I.signedtxid));
sleep(10);
}
printf("wait for alicepayment\n");
if (LP_waitfor(swap->N.pair, swap, bobwaittimeout + alicewaittimeout, LP_verify_alicepayment) < 0) {
err = -2006, printf("error waiting for alicepayment\n");
}
}
if (error == 0)
if (err == 0)
{
LP_swap_critical = (uint32_t)time(NULL);
if ( basilisk_bobscripts_set(swap,0,1) < 0 )

Loading…
Cancel
Save