diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index 9712f414d..f80f6fc81 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -198,6 +198,11 @@ uint8_t LP_etomic_verify_alice_payment(struct basilisk_swap *swap, char *txId) char *LP_etomicalice_reclaims_payment(struct LP_swap_remember *swap) { + EthTxReceipt receipt = getEthTxReceipt(swap->alicePaymentEthTx); + if (strcmp(receipt.status, "0x1") != 0) { + printf("Alice payment receipt status failed, can't reclaim\n"); + return NULL; + } AliceReclaimsAlicePaymentInput input; BasicTxData txData; memset(&txData,0,sizeof(txData)); @@ -234,6 +239,11 @@ char *LP_etomicalice_reclaims_payment(struct LP_swap_remember *swap) char *LP_etomicbob_spends_alice_payment(struct LP_swap_remember *swap) { + EthTxReceipt receipt = getEthTxReceipt(swap->alicePaymentEthTx); + if (strcmp(receipt.status, "0x1") != 0) { + printf("Alice payment receipt status failed, can't spend\n"); + return NULL; + } BobSpendsAlicePaymentInput input; BasicTxData txData; @@ -375,6 +385,10 @@ char *LP_etomicbob_refunds_deposit(struct LP_swap_remember *swap) privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr); EthTxReceipt receipt = getEthTxReceipt(swap->bobDepositEthTx); + if (strcmp(receipt.status, "0x1") != 0) { + printf("Bob deposit receipt status failed, can't refund\n"); + return NULL; + } uint8arrayToHex(input.depositId, swap->txids[BASILISK_BOBDEPOSIT].bytes, 32); strcpy(input.aliceAddress, swap->etomicdest); sprintf(input.aliceCanClaimAfter, "%" PRIu64, receipt.blockNumber + 960); @@ -506,6 +520,10 @@ char *LP_etomicbob_reclaims_payment(struct LP_swap_remember *swap) privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr); EthTxReceipt receipt = getEthTxReceipt(swap->bobPaymentEthTx); + if (strcmp(receipt.status, "0x1") != 0) { + printf("Bob payment receipt status failed, can't reclaim\n"); + return NULL; + } uint8arrayToHex(input.paymentId, swap->txids[BASILISK_BOBPAYMENT].bytes, 32); strcpy(input.aliceAddress, swap->etomicdest); sprintf(input.bobCanClaimAfter, "%" PRIu64, receipt.blockNumber + 480); @@ -533,7 +551,10 @@ 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); - + if (strcmp(receipt.status, "0x1") != 0) { + printf("Bob payment receipt status failed, can't spend\n"); + return NULL; + } struct iguana_info *ecoin; bits256 privkey; ecoin = LP_coinfind("ETOMIC"); @@ -572,6 +593,10 @@ 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); + if (strcmp(receipt.status, "0x1") != 0) { + printf("Bob deposit receipt status failed, can't claim\n"); + return NULL; + } struct iguana_info *ecoin; bits256 privkey; diff --git a/iguana/exchanges/LP_include.h b/iguana/exchanges/LP_include.h index 28c1244f5..e2f454f9c 100644 --- a/iguana/exchanges/LP_include.h +++ b/iguana/exchanges/LP_include.h @@ -276,7 +276,7 @@ struct LP_swap_remember uint32_t finishtime,tradeid,requestid,quoteid,plocktime,dlocktime,expiration,state,otherstate; 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 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)],bobDepositEthTx[75],bobPaymentEthTx[75]; + char 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)],bobDepositEthTx[75],bobPaymentEthTx[75],alicePaymentEthTx[75]; }; struct LP_outpoint diff --git a/iguana/exchanges/LP_remember.c b/iguana/exchanges/LP_remember.c index dabd3625a..4140f90e9 100644 --- a/iguana/exchanges/LP_remember.c +++ b/iguana/exchanges/LP_remember.c @@ -75,6 +75,9 @@ void basilisk_dontforget(struct basilisk_swap *swap,struct basilisk_rawtx *rawtx if (swap->bobpayment.I.ethTxid[0] != 0) { fprintf(fp,",\"bobPaymentEthTx\":\"%s\"", swap->bobpayment.I.ethTxid); } + if (swap->alicepayment.I.ethTxid[0] != 0) { + fprintf(fp,",\"alicePaymentEthTx\":\"%s\"", swap->alicepayment.I.ethTxid); + } fprintf(fp,",\"alicecoin\":\"%s\"",swap->I.alicestr); if ( swap->I.alicetomic[0] != 0 ) @@ -901,6 +904,10 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap,int32_t forceflag) strcpy(rswap->bobPaymentEthTx, jstr(txobj,"bobPaymentEthTx")); } + if (jstr(txobj,"alicePaymentEthTx") != 0) { + strcpy(rswap->alicePaymentEthTx, jstr(txobj,"alicePaymentEthTx")); + } + if (jstr(txobj,"bobtomic") != 0) { strcpy(rswap->bobtomic, jstr(txobj,"bobtomic")); }