Browse Source

Fix remember bobtomic/alicetomic.

etomic
Artem Pikulin 7 years ago
parent
commit
222584f497
  1. 57
      iguana/exchanges/LP_etomic.c
  2. 2
      iguana/exchanges/LP_nativeDEX.c
  3. 22
      iguana/exchanges/LP_remember.c
  4. 14
      iguana/exchanges/LP_transaction.c

57
iguana/exchanges/LP_etomic.c

@ -29,23 +29,10 @@
#define ETOMIC_BOBCONTRACT "0x9387Fd3a016bB0205e4e131Dde886B9d2BC000A2"
#define ETOMIC_SATOSHICAT "0000000000"
int32_t LP_etomicsymbol(char *activesymbol,char *etomic,char *symbol)
{
struct iguana_info *coin;
etomic[0] = activesymbol[0] = 0;
if ( (coin= LP_coinfind(symbol)) != 0 )
{
strcpy(etomic,coin->etomic);
if ( etomic[0] != 0 )
strcpy(activesymbol,"ETOMIC");
else strcpy(activesymbol,symbol);
}
return(etomic[0] != 0);
}
char *LP_etomicalice_send_payment(struct basilisk_swap *swap)
{
AliceSendsEthPaymentInput input; AliceSendsErc20PaymentInput input20; BasicTxData txData;
// set input and txData fields from the swap data structure
memset(&txData,0,sizeof(txData));
if ( strcmp(swap->I.alicestr,"ETH") == 0 )
@ -88,6 +75,11 @@ char *LP_etomicalice_reclaims_payment(struct LP_swap_remember *swap)
memset(&txData,0,sizeof(txData));
memset(&input,0,sizeof(input));
struct iguana_info *ecoin;
bits256 privkey;
ecoin = LP_coinfind("ETOMIC");
privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr);
uint8arrayToHex(input.dealId, swap->txids[BASILISK_ALICEPAYMENT].bytes, 32);
satoshisToWei(input.amount, swap->values[BASILISK_ALICEPAYMENT]);
@ -108,7 +100,7 @@ char *LP_etomicalice_reclaims_payment(struct LP_swap_remember *swap)
strcpy(txData.from, swap->etomicsrc);
strcpy(txData.to, ETOMIC_ALICECONTRACT);
strcpy(txData.amount, "0");
uint8arrayToHex(txData.secretKey, swap->persistentPrivKey.bytes, 32);
uint8arrayToHex(txData.secretKey, privkey.bytes, 32);
return aliceReclaimsAlicePayment(input, txData);
}
@ -120,6 +112,11 @@ char *LP_etomicbob_spends_alice_payment(struct LP_swap_remember *swap)
memset(&txData,0,sizeof(txData));
memset(&input,0,sizeof(input));
struct iguana_info *ecoin;
bits256 privkey;
ecoin = LP_coinfind("ETOMIC");
privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr);
uint8arrayToHex(input.dealId, swap->txids[BASILISK_ALICEPAYMENT].bytes, 32);
satoshisToWei(input.amount, swap->destamount);
@ -140,7 +137,7 @@ char *LP_etomicbob_spends_alice_payment(struct LP_swap_remember *swap)
strcpy(txData.from, swap->etomicsrc);
strcpy(txData.to, ETOMIC_ALICECONTRACT);
strcpy(txData.amount, "0");
uint8arrayToHex(txData.secretKey, swap->persistentPrivKey.bytes, 32);
uint8arrayToHex(txData.secretKey, privkey.bytes, 32);
return bobSpendsAlicePayment(input, txData);
}
@ -169,6 +166,11 @@ char *LP_etomicbob_refunds_deposit(struct LP_swap_remember *swap)
memset(&txData,0,sizeof(txData));
memset(&input,0,sizeof(input));
struct iguana_info *ecoin;
bits256 privkey;
ecoin = LP_coinfind("ETOMIC");
privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr);
EthTxReceipt receipt = getEthTxReceipt(swap->bobDepositEthTx);
uint8arrayToHex(input.depositId, swap->txids[BASILISK_BOBDEPOSIT].bytes, 32);
strcpy(input.aliceAddress, swap->etomicdest);
@ -191,7 +193,7 @@ char *LP_etomicbob_refunds_deposit(struct LP_swap_remember *swap)
strcpy(txData.from, swap->etomicsrc);
strcpy(txData.to, ETOMIC_BOBCONTRACT);
strcpy(txData.amount, "0");
uint8arrayToHex(txData.secretKey, swap->persistentPrivKey.bytes, 32);
uint8arrayToHex(txData.secretKey, privkey.bytes, 32);
return bobRefundsDeposit(input, txData);
}
@ -220,6 +222,11 @@ char *LP_etomicbob_reclaims_payment(struct LP_swap_remember *swap)
memset(&txData,0,sizeof(txData));
memset(&input,0,sizeof(input));
struct iguana_info *ecoin;
bits256 privkey;
ecoin = LP_coinfind("ETOMIC");
privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr);
EthTxReceipt receipt = getEthTxReceipt(swap->bobPaymentEthTx);
uint8arrayToHex(input.paymentId, swap->txids[BASILISK_BOBPAYMENT].bytes, 32);
strcpy(input.aliceAddress, swap->etomicdest);
@ -236,7 +243,7 @@ char *LP_etomicbob_reclaims_payment(struct LP_swap_remember *swap)
strcpy(txData.from, swap->etomicsrc);
strcpy(txData.to, ETOMIC_BOBCONTRACT);
strcpy(txData.amount, "0");
uint8arrayToHex(txData.secretKey, swap->persistentPrivKey.bytes, 32);
uint8arrayToHex(txData.secretKey, privkey.bytes, 32);
return bobReclaimsBobPayment(input, txData);
}
@ -249,6 +256,11 @@ char *LP_etomicalice_spends_bob_payment(struct LP_swap_remember *swap)
memset(&input,0,sizeof(input));
EthTxReceipt receipt = getEthTxReceipt(swap->bobPaymentEthTx);
struct iguana_info *ecoin;
bits256 privkey;
ecoin = LP_coinfind("ETOMIC");
privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr);
uint8arrayToHex(input.paymentId, swap->txids[BASILISK_BOBPAYMENT].bytes, 32);
satoshisToWei(input.amount, swap->values[BASILISK_BOBPAYMENT]);
sprintf(input.bobCanClaimAfter, "%" PRIu64, receipt.blockNumber + 480);
@ -270,7 +282,7 @@ char *LP_etomicalice_spends_bob_payment(struct LP_swap_remember *swap)
strcpy(txData.from, swap->etomicdest);
strcpy(txData.to, ETOMIC_BOBCONTRACT);
strcpy(txData.amount, "0");
uint8arrayToHex(txData.secretKey, swap->persistentPrivKey.bytes, 32);
uint8arrayToHex(txData.secretKey, privkey.bytes, 32);
return aliceSpendsBobPayment(input, txData);
}
@ -283,6 +295,11 @@ char *LP_etomicalice_claims_bob_deposit(struct LP_swap_remember *swap)
memset(&input,0,sizeof(input));
EthTxReceipt receipt = getEthTxReceipt(swap->bobDepositEthTx);
struct iguana_info *ecoin;
bits256 privkey;
ecoin = LP_coinfind("ETOMIC");
privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr);
uint8arrayToHex(input.depositId, swap->txids[BASILISK_BOBDEPOSIT].bytes, 32);
satoshisToWei(input.amount, swap->values[BASILISK_BOBDEPOSIT]);
sprintf(input.aliceCanClaimAfter, "%" PRIu64, receipt.blockNumber + 960);
@ -299,7 +316,7 @@ char *LP_etomicalice_claims_bob_deposit(struct LP_swap_remember *swap)
strcpy(txData.from, swap->etomicdest);
strcpy(txData.to, ETOMIC_BOBCONTRACT);
strcpy(txData.amount, "0");
uint8arrayToHex(txData.secretKey, swap->persistentPrivKey.bytes, 32);
uint8arrayToHex(txData.secretKey, privkey.bytes, 32);
return aliceClaimsBobDeposit(input, txData);
}

2
iguana/exchanges/LP_nativeDEX.c

@ -174,11 +174,11 @@ char *blocktrail_listtransactions(char *symbol,char *coinaddr,int32_t num,int32_
#include "LP_NXT.c"
#include "LP_cache.c"
#include "LP_RTmetrics.c"
#include "LP_etomic.c"
#include "LP_utxo.c"
#include "LP_prices.c"
#include "LP_scan.c"
#include "LP_transaction.c"
#include "LP_etomic.c"
#include "LP_stats.c"
#include "LP_remember.c"
#include "LP_instantdex.c"

22
iguana/exchanges/LP_remember.c

@ -869,6 +869,14 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap,int32_t forceflag)
strcpy(rswap->bobPaymentEthTx, jstr(txobj,"bobPaymentEthTx"));
}
if (jstr(txobj,"bobtomic") != 0) {
strcpy(rswap->bobtomic, jstr(txobj,"bobtomic"));
}
if (jstr(txobj,"alicetomic") != 0) {
strcpy(rswap->alicetomic, jstr(txobj,"alicetomic"));
}
rswap->txids[i] = txid;
if ( jstr(txobj,"Apayment") != 0 )
safecopy(rswap->alicepaymentaddr,jstr(txobj,"Apayment"),sizeof(rswap->alicepaymentaddr));
@ -941,20 +949,6 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap,int32_t forceflag)
}
}
struct iguana_info *ecoin,*coin;
if (rswap->iambob == 1) {
coin = LP_coinfind(rswap->bobcoin);
} else {
coin = LP_coinfind(rswap->alicecoin);
}
bits256 privkey = LP_privkey(coin->symbol,coin->smartaddr,coin->taddr);
if (coin->etomic[0] != 0) {
if ((ecoin= LP_coinfind("ETOMIC")) != 0) {
privkey = LP_privkey(ecoin->symbol, ecoin->smartaddr, ecoin->taddr);
}
}
rswap->persistentPrivKey = privkey;
free_json(txobj);
} //else printf("no symbol\n");
free(fstr);

14
iguana/exchanges/LP_transaction.c

@ -1863,6 +1863,20 @@ int32_t basilisk_swapuserdata(uint8_t *userdata,bits256 privkey,int32_t ifpath,b
OP_HASH160 <hash(alice_privM)> OP_EQUALVERIFY <alice_pubA0> OP_CHECKSIG
OP_ENDIF*/
int32_t LP_etomicsymbol(char *activesymbol,char *etomic,char *symbol)
{
struct iguana_info *coin;
etomic[0] = activesymbol[0] = 0;
if ( (coin= LP_coinfind(symbol)) != 0 )
{
strcpy(etomic,coin->etomic);
if ( etomic[0] != 0 )
strcpy(activesymbol,"ETOMIC");
else strcpy(activesymbol,symbol);
}
return(etomic[0] != 0);
}
int32_t basilisk_bobpayment_reclaim(struct basilisk_swap *swap,int32_t delay)
{
static bits256 zero;

Loading…
Cancel
Save