Browse Source

Use INSTANTDEX_PUBKEY ETH addr to send fees.

patch-3
Artem Pikulin 7 years ago
parent
commit
2c37c827d7
  1. 20
      iguana/exchanges/LP_etomic.c
  2. 10
      iguana/exchanges/etomicswap/bob.c
  3. 1
      iguana/exchanges/etomicswap/etomiclib.h

20
iguana/exchanges/LP_etomic.c

@ -28,15 +28,23 @@ int32_t LP_etomic_wait_for_confirmation(char *txId)
return(waitForConfirmation(txId)); return(waitForConfirmation(txId));
} }
void LP_etomic_pubkeystr_to_addr(char *pubkey, char *output)
{
char *address = pubKey2Addr(pubkey);
strcpy(output, address);
free(address);
}
char *LP_etomicalice_send_fee(struct basilisk_swap *swap) char *LP_etomicalice_send_fee(struct basilisk_swap *swap)
{ {
char amount[100], secretKey[70]; char amount[100], secretKey[70], dexaddr[50];
satoshisToWei(amount, swap->myfee.I.amount); satoshisToWei(amount, swap->myfee.I.amount);
uint8arrayToHex(secretKey, swap->persistent_privkey.bytes, 32); uint8arrayToHex(secretKey, swap->persistent_privkey.bytes, 32);
LP_etomic_pubkeystr_to_addr(INSTANTDEX_PUBKEY, dexaddr);
if (strcmp(swap->I.alicestr,"ETH") == 0 ) { if (strcmp(swap->I.alicestr,"ETH") == 0 ) {
return(sendEth(ETH_FEE_ACCEPTOR, amount, secretKey, 1)); return(sendEth(dexaddr, amount, secretKey, 1));
} else { } else {
return(sendErc20(swap->I.alicetomic, ETH_FEE_ACCEPTOR, amount, secretKey, 1)); return(sendErc20(swap->I.alicetomic, dexaddr, amount, secretKey, 1));
} }
} }
@ -52,8 +60,10 @@ uint8_t LP_etomic_verify_alice_fee(struct basilisk_swap *swap)
return(0); return(0);
} }
char dexaddr[50];
LP_etomic_pubkeystr_to_addr(INSTANTDEX_PUBKEY, dexaddr);
if ( strcmp(swap->I.alicestr,"ETH") == 0 ) { if ( strcmp(swap->I.alicestr,"ETH") == 0 ) {
if (strcmp(data.to, ETH_FEE_ACCEPTOR) != 0) { if (strcmp(data.to, dexaddr) != 0) {
printf("Alice fee %s was sent to wrong address %s\n", swap->otherfee.I.ethTxid, data.to); printf("Alice fee %s was sent to wrong address %s\n", swap->otherfee.I.ethTxid, data.to);
return(0); return(0);
} }
@ -70,7 +80,7 @@ uint8_t LP_etomic_verify_alice_fee(struct basilisk_swap *swap)
} }
char weiAmount[70]; char weiAmount[70];
satoshisToWei(weiAmount, swap->otherfee.I.amount); satoshisToWei(weiAmount, swap->otherfee.I.amount);
return(verifyAliceErc20FeeData(swap->I.alicetomic, ETH_FEE_ACCEPTOR, weiAmount, data.input)); return(verifyAliceErc20FeeData(swap->I.alicetomic, dexaddr, weiAmount, data.input));
} }
} }

10
iguana/exchanges/etomicswap/bob.c

@ -330,11 +330,14 @@ int main(int argc, char** argv)
default: default:
return 1; return 1;
} }
/*
char *pubkey = getPubKeyFromPriv(getenv("BOB_PK")); char *pubkey = getPubKeyFromPriv(getenv("BOB_PK"));
printf("pubkey: %s\n", pubkey); printf("pubkey: %s\n", pubkey);
free(pubkey); free(pubkey);
char *address = pubKey2Addr("03bc2c7ba671bae4a6fc835244c9762b41647b9827d4780a89a949b984a8ddcc06");
printf("address: %s\n", address);
free(address);
uint64_t satoshis = 100000000; uint64_t satoshis = 100000000;
char weiBuffer[100]; char weiBuffer[100];
satoshisToWei(weiBuffer, satoshis); satoshisToWei(weiBuffer, satoshis);
@ -346,16 +349,15 @@ int main(int argc, char** argv)
uint64_t tokenAllowance = getErc20Allowance(bobAddress, bobContractAddress, tokenAddress); uint64_t tokenAllowance = getErc20Allowance(bobAddress, bobContractAddress, tokenAddress);
printf("allowance: %" PRIu64 "\n", tokenAllowance); printf("allowance: %" PRIu64 "\n", tokenAllowance);
char *sendEthTx = sendEth(bobAddress, "100000000000000", getenv("BOB_PK")); char *sendEthTx = sendEth(bobAddress, "100000000000000", getenv("BOB_PK"), 0);
printf("sent ETH: %s\n", sendEthTx); printf("sent ETH: %s\n", sendEthTx);
free(sendEthTx); free(sendEthTx);
char *sendErc20Tx = sendErc20(tokenAddress, bobAddress, "100000000000000", getenv("BOB_PK")); char *sendErc20Tx = sendErc20(tokenAddress, bobAddress, "100000000000000", getenv("BOB_PK"), 0);
printf("sent Erc20: %s\n", sendErc20Tx); printf("sent Erc20: %s\n", sendErc20Tx);
free(sendErc20Tx); free(sendErc20Tx);
uint64_t gasPrice = getGasPriceFromStation(); uint64_t gasPrice = getGasPriceFromStation();
printf("gasPrice: %" PRIu64 "\n", gasPrice); printf("gasPrice: %" PRIu64 "\n", gasPrice);
*/
return 0; return 0;
} }

1
iguana/exchanges/etomicswap/etomiclib.h

@ -16,7 +16,6 @@ extern "C" {
#endif #endif
#define EMPTY_ETH_TX_ID "0x0000000000000000000000000000000000000000000000000000000000000000" #define EMPTY_ETH_TX_ID "0x0000000000000000000000000000000000000000000000000000000000000000"
#define ETH_FEE_ACCEPTOR "0x485d2cc2d13a9e12e4b53d606db1c8adc884fb8a"
typedef struct { typedef struct {
char from[65]; char from[65];

Loading…
Cancel
Save