Browse Source

Send Alice's ETH payment and claim it by Bob.

etomic
Artem Pikulin 7 years ago
parent
commit
d7945c24db
  1. 69
      iguana/exchanges/LP_etomic.c
  2. 2
      iguana/exchanges/LP_include.h
  3. 36
      iguana/exchanges/LP_remember.c
  4. 2
      iguana/exchanges/LP_swap.c
  5. 199
      iguana/exchanges/etomicswap/bob.c
  6. 18
      iguana/exchanges/etomicswap/etomiclib.cpp
  7. 138
      iguana/exchanges/etomicswap/etomiclib.h
  8. 8
      iguana/exchanges/mm.c

69
iguana/exchanges/LP_etomic.c

@ -41,7 +41,7 @@ int32_t LP_etomicsymbol(char *activesymbol,char *etomic,char *symbol)
return(etomic[0] != 0);
}
char *LP_etomicalice_start(struct basilisk_swap *swap)
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
@ -49,14 +49,79 @@ char *LP_etomicalice_start(struct basilisk_swap *swap)
if ( strcmp(swap->I.alicestr,"ETH") == 0 )
{
memset(&input,0,sizeof(input));
strcpy(input.bobAddress, swap->I.etomicsrc);
uint8arrayToHex(input.bobHash, swap->I.secretBn, 20);
uint8arrayToHex(input.aliceHash, swap->I.secretAm, 20);
uint8arrayToHex(input.dealId, swap->alicepayment.utxotxid.bytes, 32);
strcpy(txData.from, swap->I.etomicdest);
strcpy(txData.to, ETOMIC_ALICECONTRACT);
satoshisToWei(txData.amount, swap->I.alicesatoshis);
uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32);
return(aliceSendsEthPayment(input,txData));
}
else
{
memset(&input20,0,sizeof(input20));
strcpy(input20.bobAddress, swap->I.etomicdest);
uint8arrayToHex(input20.bobHash, swap->I.secretBn, 20);
uint8arrayToHex(input20.aliceHash, swap->I.secretAm, 20);
uint8arrayToHex(input20.dealId, swap->alicepayment.utxotxid.bytes, 32);
strcpy(input20.tokenAddress, swap->I.alicetomic);
satoshisToWei(input20.amount, swap->I.alicesatoshis);
strcpy(txData.from, swap->I.etomicsrc);
strcpy(txData.to, ETOMIC_ALICECONTRACT);
strcpy(txData.amount, "0");
uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32);
return(aliceSendsErc20Payment(input20,txData));
}
return(0);
}
char *LP_etomicalice_reclaims_payment(struct basilisk_swap *swap)
{
AliceReclaimsAlicePaymentInput input;
BasicTxData txData;
memset(&txData,0,sizeof(txData));
memset(&input,0,sizeof(input));
uint8arrayToHex(input.dealId, swap->alicepayment.utxotxid.bytes, 32);
satoshisToWei(input.amount, swap->I.alicesatoshis);
strcpy(input.tokenAddress, swap->I.alicetomic);
strcpy(input.bobAddress, swap->I.etomicdest);
uint8arrayToHex(input.aliceHash, swap->I.secretAm, 20);
uint8arrayToHex(input.bobSecret, swap->I.secretBn256, 32);
strcpy(txData.from, swap->I.etomicsrc);
strcpy(txData.to, ETOMIC_ALICECONTRACT);
strcpy(txData.amount, "0");
uint8arrayToHex(txData.secretKey, swap->persistent_privkey.bytes, 32);
}
char *LP_etomicbob_spends_alice_payment(struct LP_swap_remember *swap)
{
BobSpendsAlicePaymentInput input;
BasicTxData txData;
memset(&txData,0,sizeof(txData));
memset(&input,0,sizeof(input));
uint8arrayToHex(input.dealId, swap->txids[BASILISK_ALICEPAYMENT].bytes, 32);
satoshisToWei(input.amount, swap->destamount);
if (swap->alicetomic[0] != 0)
strcpy(input.tokenAddress, swap->alicetomic);
else
strcpy(input.tokenAddress, "0x0000000000000000000000000000000000000000");
strcpy(input.aliceAddress, swap->etomicdest);
uint8arrayToHex(input.aliceSecret, swap->secretAm256, 32);
uint8arrayToHex(input.bobHash, swap->secretBn, 20);
strcpy(txData.from, swap->etomicsrc);
strcpy(txData.to, ETOMIC_ALICECONTRACT);
strcpy(txData.amount, "0");
uint8arrayToHex(txData.secretKey, swap->persistentPrivKey.bytes, 32);
return bobSpendsAlicePayment(input, txData);
}
int32_t LP_etomic_priv2addr(char *coinaddr,bits256 privkey)

2
iguana/exchanges/LP_include.h

@ -270,7 +270,7 @@ char *txnames[] = { "alicespend", "bobspend", "bobpayment", "alicepayment", "bob
struct LP_swap_remember
{
bits256 pubA0,pubB0,pubB1,privAm,privBn,paymentspent,Apaymentspent,depositspent,myprivs[2],txids[sizeof(txnames)/sizeof(*txnames)];
bits256 persistentPrivKey,pubA0,pubB0,pubB1,privAm,privBn,paymentspent,Apaymentspent,depositspent,myprivs[2],txids[sizeof(txnames)/sizeof(*txnames)];
uint64_t Atxfee,Btxfee,srcamount,destamount,aliceid;
int64_t values[sizeof(txnames)/sizeof(*txnames)];
uint32_t finishtime,tradeid,requestid,quoteid,plocktime,dlocktime,expiration,state,otherstate;

36
iguana/exchanges/LP_remember.c

@ -70,6 +70,11 @@ 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);
char persistentPrivKeyStr[100];
bits256_str(persistentPrivKeyStr,swap->persistent_privkey);
fprintf(fp,",\"persistentPrivKey\":\"%s\"",persistentPrivKeyStr);
fprintf(fp,",\"alicecoin\":\"%s\"",swap->I.alicestr);
if ( swap->I.alicetomic[0] != 0 )
fprintf(fp,",\"alicetomic\":\"%s\"",swap->I.alicetomic);
@ -128,6 +133,7 @@ void basilisk_dontforget(struct basilisk_swap *swap,struct basilisk_rawtx *rawtx
init_hexbytes_noT(secretBn256str,swap->I.secretBn256,32);
fprintf(fp,",\"secretBn256\":\"%s\"",secretBn256str);
}
for (i=0; i<2; i++)
if ( bits256_nonz(swap->I.myprivs[i]) != 0 )
fprintf(fp,",\"myprivs%d\":\"%s\"",i,bits256_str(str,swap->I.myprivs[i]));
@ -845,6 +851,19 @@ int32_t LP_swap_load(struct LP_swap_remember *rswap,int32_t forceflag)
free_json(txobj);
continue;
}
if (jstr(txobj,"etomicsrc") != 0)
{
strcpy(rswap->etomicsrc,jstr(txobj,"etomicsrc"));
}
if (jstr(txobj,"etomicdest") != 0)
{
strcpy(rswap->etomicdest,jstr(txobj,"etomicdest"));
}
rswap->persistentPrivKey = jbits256(txobj,"persistentPrivKey");
rswap->txids[i] = txid;
if ( jstr(txobj,"Apayment") != 0 )
safecopy(rswap->alicepaymentaddr,jstr(txobj,"Apayment"),sizeof(rswap->alicepaymentaddr));
@ -1019,24 +1038,8 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti
srcAdest = srcBdest = destAdest = destBdest = 0;
alice = LP_coinfind(rswap.alicecoin);
bob = LP_coinfind(rswap.bobcoin);
if ( alice != 0 )
strcpy(etomicdest,alice->smartaddr);
else etomicdest[0] = 0;
if ( bob != 0 )
strcpy(etomicsrc,bob->smartaddr);
else etomicsrc[0] = 0;
LP_etomicsymbol(bobstr,bobtomic,rswap.src);
if ( bobtomic[0] != 0 )
{
if ( (coin= LP_coinfind(rswap.src)) != 0 )
strcpy(etomicsrc,coin->smartaddr);
}
LP_etomicsymbol(alicestr,alicetomic,rswap.dest);
if ( alicetomic[0] != 0 )
{
if ( (coin= LP_coinfind(rswap.dest)) != 0 )
strcpy(etomicdest,coin->smartaddr);
}
if ( rswap.bobcoin[0] == 0 || rswap.alicecoin[0] == 0 || strcmp(rswap.bobcoin,bobstr) != 0 || strcmp(rswap.alicecoin,alicestr) != 0 )
{
//printf("legacy r%u-q%u DB SWAPS.(%u %u) %llu files BOB.(%s) Alice.(%s) src.(%s) dest.(%s)\n",requestid,quoteid,rswap.requestid,rswap.quoteid,(long long)rswap.aliceid,rswap.bobcoin,rswap.alicecoin,rswap.src,rswap.dest);
@ -1275,6 +1278,7 @@ cJSON *basilisk_remember(int64_t *KMDtotals,int64_t *BTCtotals,uint32_t requesti
if ( (rswap.txbytes[BASILISK_BOBSPEND]= basilisk_swap_Aspend("bobspend",rswap.alicecoin,rswap.Atxfee,alice->wiftaddr,alice->taddr,alice->pubtype,alice->p2shtype,alice->isPoS,alice->wiftype,ctx,rswap.privAm,rswap.privBn,rswap.txids[BASILISK_ALICEPAYMENT],0,rswap.pubkey33,rswap.expiration,&rswap.values[BASILISK_BOBSPEND],rswap.alicepaymentaddr,alice->zcash)) != 0 )
{
//printf("bobspend.(%s)\n",rswap.txbytes[BASILISK_BOBSPEND]);
LP_etomicbob_spends_alice_payment(&rswap);
}
}
LP_txbytes_update("bobspend",rswap.alicecoin,rswap.txbytes[BASILISK_BOBSPEND],&rswap.txids[BASILISK_BOBSPEND],&rswap.Apaymentspent,&rswap.sentflags[BASILISK_BOBSPEND]);

2
iguana/exchanges/LP_swap.c

@ -867,7 +867,7 @@ void LP_aliceloop(void *_swap)
LP_swap_critical = (uint32_t)time(NULL);
if ( swap->I.alicetomic[0] != 0 )
{
// artem: do stuff alice needs to do at the beginning of the swap, before dexfee
LP_etomicalice_send_payment(swap);
}
if ( LP_swapdata_rawtxsend(swap->N.pair,swap,0x80,data,maxlen,&swap->myfee,0x40,0) == 0 )
printf("error sending alicefee\n");

199
iguana/exchanges/etomicswap/bob.c

@ -5,6 +5,7 @@
#include <curl/curl.h>
#include <stdlib.h>
#include <inttypes.h>
#include <string.h>
#include "etomiclib.h"
char* bobContractAddress = "0x9387Fd3a016bB0205e4e131Dde886B9d2BC000A2";
@ -36,144 +37,142 @@ int main(int argc, char** argv)
switch (action)
{
case BOB_ETH_DEPOSIT:
txData.amount = "1000000000000000000";
txData.from = bobAddress;
txData.to = bobContractAddress;
txData.secretKey = getenv("BOB_PK");
BobSendsEthDepositInput input = {
.aliceAddress = aliceAddress,
.depositId = argv[2],
.bobHash = argv[3]
};
strcpy(txData.amount, "1000000000000000000");
strcpy(txData.from, bobAddress);
strcpy(txData.to, bobContractAddress);
strcpy(txData.secretKey, getenv("BOB_PK"));
BobSendsEthDepositInput input;
strcpy(input.aliceAddress, aliceAddress);
strcpy(input.depositId, argv[2]);
strcpy(input.bobHash, argv[3]);
result = bobSendsEthDeposit(input, txData);
printf("%s\n", result);
free(result);
break;
case BOB_ERC20_DEPOSIT:
txData.amount = "0";
txData.from = bobAddress;
txData.to = bobContractAddress;
txData.secretKey = getenv("BOB_PK");
strcpy(txData.amount, "0");
strcpy(txData.from, bobAddress);
strcpy(txData.to, bobContractAddress);
strcpy(txData.secretKey, getenv("BOB_PK"));
BobSendsErc20DepositInput input1 = {
.depositId = argv[2],
.amount = "1000000000000000000",
.aliceAddress = aliceAddress,
.bobHash = argv[3],
.tokenAddress = tokenAddress
.amount = "1000000000000000000"
};
strcpy(input1.depositId, argv[2]);
strcpy(input1.aliceAddress, aliceAddress);
strcpy(input1.bobHash, argv[3]);
strcpy(input1.tokenAddress, tokenAddress);
result = bobSendsErc20Deposit(input1, txData);
printf("%s\n", result);
free(result);
break;
case BOB_CLAIMS_DEPOSIT:
txData.amount = "0";
txData.from = bobAddress;
txData.to = bobContractAddress;
txData.secretKey = getenv("BOB_PK");
BobRefundsDepositInput input2 = {
.depositId = argv[2],
.amount = "1000000000000000000",
.aliceAddress = aliceAddress,
.tokenAddress = argv[3],
.aliceCanClaimAfter = argv[4],
.bobSecret = argv[5]
};
strcpy(txData.amount, "0");
strcpy(txData.from, bobAddress);
strcpy(txData.to, bobContractAddress);
strcpy(txData.secretKey, getenv("BOB_PK"));
BobRefundsDepositInput input2;
strcpy(input2.depositId, argv[2]);
strcpy(input2.amount, "1000000000000000000");
strcpy(input2.aliceAddress, aliceAddress);
strcpy(input2.tokenAddress, argv[3]);
strcpy(input2.aliceCanClaimAfter, argv[4]);
strcpy(input2.bobSecret, argv[5]);
result = bobRefundsDeposit(input2, txData);
printf("%s\n", result);
free(result);
break;
case ALICE_CLAIMS_DEPOSIT:
txData.amount = "0";
txData.from = aliceAddress;
txData.to = bobContractAddress;
txData.secretKey = getenv("ALICE_PK");
AliceClaimsBobDepositInput input3 = {
.depositId = argv[2],
.amount = "1000000000000000000",
.bobAddress = bobAddress,
.tokenAddress = argv[3],
.aliceCanClaimAfter = argv[4],
.bobHash = argv[5]
};
strcpy(txData.amount, "0");
strcpy(txData.from, aliceAddress);
strcpy(txData.to, bobContractAddress);
strcpy(txData.secretKey, getenv("ALICE_PK"));
AliceClaimsBobDepositInput input3;
strcpy(input3.depositId, argv[2]);
strcpy(input3.amount, "1000000000000000000");
strcpy(input3.bobAddress, bobAddress);
strcpy(input3.tokenAddress, argv[3]);
strcpy(input3.aliceCanClaimAfter, argv[4]);
strcpy(input3.bobHash, argv[5]);
result = aliceClaimsBobDeposit(input3, txData);
printf("%s\n", result);
free(result);
break;
case BOB_ETH_PAYMENT:
txData.amount = "1000000000000000000";
txData.from = bobAddress;
txData.to = bobContractAddress;
txData.secretKey = getenv("BOB_PK");
BobSendsEthPaymentInput input4 = {
.paymentId = argv[2],
.aliceHash = argv[3],
.aliceAddress = aliceAddress
};
strcpy(txData.amount, "1000000000000000000");
strcpy(txData.from, bobAddress);
strcpy(txData.to, bobContractAddress);
strcpy(txData.secretKey, getenv("BOB_PK"));
BobSendsEthPaymentInput input4;
strcpy(input4.paymentId, argv[2]);
strcpy(input4.aliceHash, argv[3]);
strcpy(input4.aliceAddress, aliceAddress);
result = bobSendsEthPayment(input4, txData);
printf("%s\n", result);
free(result);
break;
case BOB_ERC20_PAYMENT:
txData.amount = "0";
txData.from = bobAddress;
txData.to = bobContractAddress;
txData.secretKey = getenv("BOB_PK");
BobSendsErc20PaymentInput input5 = {
.paymentId = argv[2],
.amount = "1000000000000000000",
.tokenAddress = tokenAddress,
.aliceAddress = aliceAddress,
.aliceHash = argv[3]
};
strcpy(txData.amount, "0");
strcpy(txData.from, bobAddress);
strcpy(txData.to, bobContractAddress);
strcpy(txData.secretKey, getenv("BOB_PK"));
BobSendsErc20PaymentInput input5;
strcpy(input5.paymentId, argv[2]);
strcpy(input5.amount, "1000000000000000000");
strcpy(input5.tokenAddress, tokenAddress);
strcpy(input5.aliceAddress, aliceAddress);
strcpy(input5.aliceHash, argv[3]);
result = bobSendsErc20Payment(input5, txData);
printf("%s\n", result);
free(result);
break;
case BOB_CLAIMS_PAYMENT:
txData.amount = "0";
txData.from = bobAddress;
txData.to = bobContractAddress;
txData.secretKey = getenv("BOB_PK");
BobReclaimsBobPaymentInput input6 = {
.paymentId = argv[2],
.aliceAddress = aliceAddress,
.amount = "1000000000000000000",
.tokenAddress = argv[3],
.bobCanClaimAfter = argv[4],
.aliceHash = argv[5]
};
strcpy(txData.amount, "0");
strcpy(txData.from, bobAddress);
strcpy(txData.to, bobContractAddress);
strcpy(txData.secretKey, getenv("BOB_PK"));
BobReclaimsBobPaymentInput input6;
strcpy(input6.paymentId, argv[2]);
strcpy(input6.aliceAddress, aliceAddress);
strcpy(input6.amount, "1000000000000000000");
strcpy(input6.tokenAddress, argv[3]);
strcpy(input6.bobCanClaimAfter, argv[4]);
strcpy(input6.aliceHash, argv[5]);
result = bobReclaimsBobPayment(input6, txData);
printf("%s\n", result);
free(result);
break;
case ALICE_CLAIMS_PAYMENT:
txData.amount = "0";
txData.from = aliceAddress;
txData.to = bobContractAddress;
txData.secretKey = getenv("ALICE_PK");
AliceSpendsBobPaymentInput input7 = {
.paymentId = argv[2],
.bobAddress = bobAddress,
.amount = "1000000000000000000",
.tokenAddress = argv[3],
.bobCanClaimAfter = argv[4],
.aliceSecret = argv[5]
};
strcpy(txData.amount, "0");
strcpy(txData.from, aliceAddress);
strcpy(txData.to, bobContractAddress);
strcpy(txData.secretKey, getenv("ALICE_PK"));
AliceSpendsBobPaymentInput input7;
strcpy(input7.paymentId, argv[2]);
strcpy(input7.bobAddress, bobAddress);
strcpy(input7.amount, "1000000000000000000");
strcpy(input7.tokenAddress, argv[3]);
strcpy(input7.bobCanClaimAfter, argv[4]);
strcpy(input7.aliceSecret, argv[5]);
result = aliceSpendsBobPayment(input7, txData);
printf("%s\n", result);
@ -198,5 +197,19 @@ int main(int argc, char** argv)
default:
return 1;
}
char *pubkey = getPubKeyFromPriv(getenv("BOB_PK"));
printf("pubkey: %s\n", pubkey);
free(pubkey);
uint8_t test[2];
test[0] = 100;
test[1] = 100;
char buf[30];
uint8arrayToHex(buf, test, 2);
printf("hex: %s\n", buf);
uint64_t satoshis = 100000000;
char weiBuffer[100];
satoshisToWei(weiBuffer, satoshis);
printf("wei: %s\n", weiBuffer);
return 0;
}

18
iguana/exchanges/etomicswap/etomiclib.cpp

@ -7,6 +7,8 @@
#include <cpp-ethereum/libethcore/Common.h>
#include <cpp-ethereum/libethcore/CommonJS.h>
#include <cpp-ethereum/libethcore/TransactionBase.h>
#include <inttypes.h>
using namespace dev;
using namespace dev::eth;
@ -355,3 +357,19 @@ uint64_t getErc20Balance(char* address, char* tokenAddress)
free(hexBalance);
return static_cast<uint64_t>(balance);
}
void uint8arrayToHex(char *dest, uint8_t *input, int len)
{
strcpy(dest, "0x");
for (int i = 0; i < len; i++)
{
sprintf(dest + (i + 1) * 2, "%02x", input[i]);
}
dest[(len + 1) * 2] = '\0';
}
void satoshisToWei(char *dest, uint64_t input)
{
sprintf(dest, "%" PRIu64, input);
strcat(dest, "0000000000");
}

138
iguana/exchanges/etomicswap/etomiclib.h

@ -7,111 +7,111 @@
extern "C" {
#endif
typedef struct {
char* from;
char* to;
char* amount;
char* secretKey;
char from[65];
char to[65];
char amount[100];
char secretKey[70];
} BasicTxData;
typedef struct {
char* dealId;
char* bobAddress;
char* aliceHash;
char* bobHash;
char dealId[70];
char bobAddress[65];
char aliceHash[65];
char bobHash[65];
} AliceSendsEthPaymentInput;
typedef struct {
char* dealId;
char* amount;
char* tokenAddress;
char* bobAddress;
char* aliceHash;
char* bobHash;
char dealId[70];
char amount[100];
char tokenAddress[65];
char bobAddress[65];
char aliceHash[65];
char bobHash[65];
} AliceSendsErc20PaymentInput;
typedef struct {
char* dealId;
char* amount;
char* tokenAddress;
char* bobAddress;
char* aliceHash;
char* bobSecret;
char dealId[70];
char amount[100];
char tokenAddress[65];
char bobAddress[65];
char aliceHash[65];
char bobSecret[70];
} AliceReclaimsAlicePaymentInput;
typedef struct {
char* dealId;
char* amount;
char* tokenAddress;
char* aliceAddress;
char* aliceSecret;
char* bobHash;
char dealId[70];
char amount[100];
char tokenAddress[65];
char aliceAddress[65];
char aliceSecret[70];
char bobHash[65];
} BobSpendsAlicePaymentInput;
typedef struct {
char* depositId;
char* aliceAddress;
char* bobHash;
char depositId[70];
char aliceAddress[65];
char bobHash[65];
} BobSendsEthDepositInput;
typedef struct {
char* depositId;
char* amount;
char* tokenAddress;
char* aliceAddress;
char* bobHash;
char depositId[70];
char amount[100];
char tokenAddress[65];
char aliceAddress[65];
char bobHash[65];
} BobSendsErc20DepositInput;
typedef struct {
char* depositId;
char* amount;
char* tokenAddress;
char* aliceAddress;
char* bobSecret;
char* aliceCanClaimAfter;
char depositId[70];
char amount[100];
char tokenAddress[65];
char aliceAddress[65];
char bobSecret[70];
char aliceCanClaimAfter[100];
} BobRefundsDepositInput;
typedef struct {
char* depositId;
char* amount;
char* tokenAddress;
char* bobAddress;
char* bobHash;
char* aliceCanClaimAfter;
char depositId[70];
char amount[100];
char tokenAddress[65];
char bobAddress[65];
char bobHash[65];
char aliceCanClaimAfter[100];
} AliceClaimsBobDepositInput;
typedef struct {
char* paymentId;
char* aliceAddress;
char* aliceHash;
char paymentId[70];
char aliceAddress[65];
char aliceHash[65];
} BobSendsEthPaymentInput;
typedef struct {
char* paymentId;
char* amount;
char* tokenAddress;
char* aliceAddress;
char* aliceHash;
char paymentId[70];
char amount[100];
char tokenAddress[65];
char aliceAddress[65];
char aliceHash[65];
} BobSendsErc20PaymentInput;
typedef struct {
char* paymentId;
char* amount;
char* tokenAddress;
char* aliceAddress;
char* aliceHash;
char* bobCanClaimAfter;
char paymentId[70];
char amount[100];
char tokenAddress[65];
char aliceAddress[65];
char aliceHash[65];
char bobCanClaimAfter[100];
} BobReclaimsBobPaymentInput;
typedef struct {
char* paymentId;
char* amount;
char* tokenAddress;
char* aliceSecret;
char* bobAddress;
char* bobCanClaimAfter;
char paymentId[70];
char amount[100];
char tokenAddress[65];
char aliceSecret[70];
char bobAddress[65];
char bobCanClaimAfter[100];
} AliceSpendsBobPaymentInput;
char* approveErc20(char* amount, char* from, char* secret);
char* approveErc20(char amount[100], char* from, char* secret);
char* aliceSendsEthPayment(AliceSendsEthPaymentInput input, BasicTxData txData);
char* aliceSendsErc20Payment(AliceSendsErc20PaymentInput input, BasicTxData txData);
char* aliceReclaimsAlicePayment(AliceReclaimsAlicePaymentInput input, BasicTxData txData);
@ -128,7 +128,9 @@ char* privKey2Addr(char* privKey);
char* pubKey2Addr(char* pubKey);
char* getPubKeyFromPriv(char* privKey);
uint64_t getEthBalance(char* address);
uint64_t getErc20Balance(char* address, char* tokenAddress);
uint64_t getErc20Balance(char* address, char tokenAddress[65]);
void uint8arrayToHex(char *dest, uint8_t *input, int len);
void satoshisToWei(char *dest, uint64_t input);
// Your prototype or Definition
#ifdef __cplusplus
}

8
iguana/exchanges/mm.c

@ -115,10 +115,10 @@ void LP_main(void *ptr)
void ETH_test()
{
BasicTxData txData; char* ethSignedTx;
txData.amount = "1000000000000000000";
txData.from = "0xA7EF3f65714AE266414C9E58bB4bAa4E6FB82B41";
txData.to = "0x9387Fd3a016bB0205e4e131Dde886B9d2BC000A2";
txData.secretKey = getenv("BOB_PK");
strcpy(txData.amount, "1000000000000000000");
strcpy(txData.from, "0xA7EF3f65714AE266414C9E58bB4bAa4E6FB82B41");
strcpy(txData.to, "0x9387Fd3a016bB0205e4e131Dde886B9d2BC000A2");
strcpy(txData.secretKey, getenv("BOB_PK"));
BobSendsEthDepositInput input = {
.aliceAddress = "0x485d2cc2d13a9e12E4b53D606DB1c8adc884fB8a",
.depositId = "0x28c5a7c25911ef59a577ddf811d0e58edb827efb0646a8a38df6e921ba53f431",

Loading…
Cancel
Save