Skip to content

Commit e040a92

Browse files
committed
catch up
2 parents 53c39e1 + 6083116 commit e040a92

File tree

10 files changed

+326
-392
lines changed

10 files changed

+326
-392
lines changed

Diff for: Cargo.lock

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: Dockerfile

+10-13
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ RUN \
1717
apt-get clean
1818

1919
#Cmake 3.12.0 supports multi-platform -j option, it allows to use all cores for concurrent build to speed up it
20-
RUN wget https://cmake.org/files/v3.12/cmake-3.12.0-rc2-Linux-x86_64.sh && \
21-
chmod +x cmake-3.12.0-rc2-Linux-x86_64.sh && \
22-
./cmake-3.12.0-rc2-Linux-x86_64.sh --skip-license --exclude-subdir --prefix=/usr && \
23-
rm -rf cmake-3.12.0-rc2-Linux-x86_64.sh
20+
RUN wget https://cmake.org/files/v3.12/cmake-3.12.0-Linux-x86_64.sh && \
21+
chmod +x cmake-3.12.0-Linux-x86_64.sh && \
22+
./cmake-3.12.0-Linux-x86_64.sh --skip-license --exclude-subdir --prefix=/usr && \
23+
rm -rf cmake-3.12.0-Linux-x86_64.sh
2424

2525
RUN \
2626
wget -O- https://sh.rustup.rs > /tmp/rustup-init.sh &&\
@@ -46,22 +46,19 @@ RUN cd /mm2 &&\
4646
# `nproc --all` is "the number of processing units available".
4747
nproc --all > /tmp/THREAD_COUNT
4848

49-
RUN cd /mm2 &&\
50-
cargo build &&\
51-
mv target/debug/libmm2.a ./ &&\
52-
cargo clean
53-
5449
RUN cd /mm2 &&\
5550
git submodule update --init --recursive
5651

5752
RUN mkdir /mm2/build && cd /mm2/build &&\
5853
cmake -DMM_VERSION="$(cat /mm2/MM_VERSION)" -j `cat /tmp/THREAD_COUNT` ..
5954

55+
#Build and clean up
56+
#Cargo build of mm2rs is triggered by cmake - ./iguana/exchanges/CMakeLists.txt#16
6057
RUN cd /mm2/build &&\
61-
cmake --build . --target marketmaker-testnet -j `cat /tmp/THREAD_COUNT`
62-
63-
RUN cd /mm2/build &&\
64-
cmake --build . --target marketmaker-mainnet -j `cat /tmp/THREAD_COUNT`
58+
cmake --build . --target marketmaker-testnet -j `cat /tmp/THREAD_COUNT` &&\
59+
cmake --build . --target marketmaker-mainnet -j `cat /tmp/THREAD_COUNT` &&\
60+
cd /mm2 &&\
61+
cargo clean
6562

6663
RUN cd /mm2/build &&\
6764
ln iguana/exchanges/marketmaker-testnet /usr/local/bin/ &&\

Diff for: iguana/exchanges/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ set(MM_LIBS
66
libcrypto777
77
libjpeg
88
libsecp256k1
9-
${CMAKE_SOURCE_DIR}/libmm2.a
9+
${CMAKE_SOURCE_DIR}/target/debug/libmm2.a
1010
dl
1111
ssl
1212
crypto

Diff for: iguana/exchanges/LP_commands.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,8 @@ version\n\
630630
}
631631

632632
if (ptr->decimals == 0 && strcmp(coin, "ETH") != 0) {
633-
ptr->decimals = getErc20DecimalsZeroOnError(ptr->etomic);
633+
extern void *LP_eth_client;
634+
ptr->decimals = get_erc20_decimals(ptr->etomic, LP_eth_client);
634635
if (ptr->decimals == 0) {
635636
return(clonestr("{\"error\":\"Could not get token decimals or token has zero decimals which is not supported!\"}"));
636637
}

Diff for: iguana/exchanges/LP_etomic.c

+8-12
Original file line numberDiff line numberDiff line change
@@ -43,17 +43,15 @@ void LP_etomic_pubkeystr_to_addr(char *pubkey, char *output)
4343

4444
char *LP_etomicalice_send_fee(struct basilisk_swap *swap)
4545
{
46-
char amount[100], secretKey[70], dexaddr[50];
47-
satoshisToWei(amount, LP_DEXFEE(swap->I.alicerealsat));
46+
char dexaddr[50];
4847
swap->myfee.I.eth_amount = LP_DEXFEE(swap->I.alicerealsat);
49-
uint8arrayToHex(secretKey, swap->persistent_privkey.bytes, 32);
5048
LP_etomic_pubkeystr_to_addr(INSTANTDEX_PUBKEY, dexaddr);
5149
if (strcmp(swap->I.alicestr,"ETH") == 0 ) {
52-
return(sendEth(dexaddr, amount, secretKey, 1, 0, 0, 1));
50+
return(send_eth(dexaddr, (uint64_t)LP_DEXFEE(swap->I.alicerealsat), 0, 0, 1, LP_eth_client));
5351
} else {
5452
struct iguana_info *alicecoin = LP_coinfind(swap->I.alicestr);
5553

56-
return(sendErc20(swap->I.alicetomic, dexaddr, amount, secretKey, 1, 0, 0, 1, alicecoin->decimals));
54+
return(send_erc20(swap->I.alicetomic, dexaddr, (uint64_t)LP_DEXFEE(swap->I.alicerealsat), 0, 0, 1, alicecoin->decimals, LP_eth_client));
5755
}
5856
}
5957

@@ -76,7 +74,7 @@ uint8_t LP_etomic_verify_alice_fee(struct basilisk_swap *swap)
7674
printf("Alice fee %s was sent to wrong address %s\n", swap->otherfee.I.ethTxid, data.to);
7775
return(0);
7876
}
79-
uint64_t txValue = weiToSatoshi(data.valueHex);
77+
uint64_t txValue = wei_to_satoshi(data.valueHex);
8078
if (txValue != LP_DEXFEE(swap->I.alicerealsat)) {
8179
printf("Alice fee %s amount %" PRIu64 " is not equal to expected %" PRId64 "\n", swap->otherfee.I.ethTxid, txValue, LP_DEXFEE(swap->I.alicerealsat));
8280
return(0);
@@ -89,9 +87,7 @@ uint8_t LP_etomic_verify_alice_fee(struct basilisk_swap *swap)
8987
printf("Alice ERC20 fee %s token address %s is not equal to expected %s\n", swap->otherfee.I.ethTxid, data.to, swap->I.alicetomic);
9088
return(0);
9189
}
92-
char weiAmount[70];
93-
satoshisToWei(weiAmount, LP_DEXFEE(swap->I.alicerealsat));
94-
return(verifyAliceErc20FeeData(swap->I.alicetomic, dexaddr, weiAmount, data.input, alicecoin->decimals));
90+
return(verify_alice_erc20_fee_data(dexaddr, (uint64_t)LP_DEXFEE(swap->I.alicerealsat), data.input, alicecoin->decimals));
9591
}
9692
}
9793

@@ -169,7 +165,7 @@ uint8_t LP_etomic_verify_alice_payment(struct basilisk_swap *swap, char *txId)
169165
}
170166
AliceSendsEthPaymentInput input; AliceSendsErc20PaymentInput input20;
171167
if ( strcmp(swap->I.alicestr,"ETH") == 0 ) {
172-
uint64_t paymentAmount = weiToSatoshi(data.valueHex);
168+
uint64_t paymentAmount = wei_to_satoshi(data.valueHex);
173169
if (paymentAmount != swap->I.alicerealsat) {
174170
printf("Alice payment amount %" PRIu64 " does not match expected %" PRIu64 "\n", paymentAmount, swap->I.alicerealsat);
175171
return(0);
@@ -380,7 +376,7 @@ uint8_t LP_etomic_verify_bob_deposit(struct basilisk_swap *swap, char *txId)
380376
memset(&input,0,sizeof(input));
381377
memset(&input20,0,sizeof(input20));
382378
if ( strcmp(swap->I.bobstr,"ETH") == 0 ) {
383-
uint64_t depositAmount = weiToSatoshi(data.valueHex);
379+
uint64_t depositAmount = wei_to_satoshi(data.valueHex);
384380
if (depositAmount != LP_DEPOSITSATOSHIS(swap->I.bobrealsat)) {
385381
printf("Bob deposit %s amount %" PRIu64 " != expected %" PRIu64 "\n", txId, depositAmount, LP_DEPOSITSATOSHIS(swap->I.bobrealsat));
386382
return(0);
@@ -535,7 +531,7 @@ uint8_t LP_etomic_verify_bob_payment(struct basilisk_swap *swap, char *txId)
535531
memset(&input,0,sizeof(input));
536532
memset(&input20,0,sizeof(input20));
537533
if ( strcmp(swap->I.bobstr,"ETH") == 0 ) {
538-
uint64_t paymentAmount = weiToSatoshi(data.valueHex);
534+
uint64_t paymentAmount = wei_to_satoshi(data.valueHex);
539535
if (paymentAmount != swap->I.bobrealsat) {
540536
printf("Bob payment %s amount %" PRIu64 " != expected %" PRIu64 "\n", txId, paymentAmount, swap->I.bobrealsat);
541537
return(0);

Diff for: iguana/exchanges/LP_transaction.c

+8-9
Original file line numberDiff line numberDiff line change
@@ -2087,7 +2087,7 @@ char *LP_movecoinbases(char *symbol)
20872087

20882088
#ifndef NOTETOMIC
20892089

2090-
char *LP_eth_tx_fee(struct iguana_info *coin, char *dest_addr, char *amount, int64_t gas, int64_t gas_price)
2090+
char *LP_eth_tx_fee(struct iguana_info *coin, char *dest_addr, uint64_t amount, int64_t gas, int64_t gas_price)
20912091
{
20922092
bits256 privkey;
20932093
cJSON *retjson = cJSON_CreateObject();
@@ -2109,9 +2109,8 @@ char *LP_eth_tx_fee(struct iguana_info *coin, char *dest_addr, char *amount, int
21092109
} else if (strcmp(coin->symbol, "ETH") == 0) {
21102110
actual_gas = 21000;
21112111
} else {
2112-
privkey = LP_privkey(coin->symbol, coin->smartaddr, coin->taddr);
2113-
uint8arrayToHex(privkey_str, privkey.bytes, 32);
2114-
actual_gas = estimate_erc20_gas(coin->etomic, dest_addr, amount, privkey_str, coin->decimals);
2112+
extern void *LP_eth_client;
2113+
actual_gas = estimate_erc20_gas(coin->etomic, dest_addr, amount, coin->decimals, LP_eth_client);
21152114
if (actual_gas == 0) {
21162115
return (clonestr("{\"error\":\"Couldn't estimate erc20 transfer gas usage!\"}"));
21172116
}
@@ -2128,7 +2127,7 @@ char *LP_eth_withdraw(struct iguana_info *coin,cJSON *argjson)
21282127
cJSON *retjson = cJSON_CreateObject();
21292128
cJSON *gas_json = cJSON_GetObjectItem(argjson, "gas");
21302129
cJSON *gas_price_json = cJSON_GetObjectItem(argjson, "gas_price");
2131-
char *dest_addr, *tx_id, privkey_str[70], amount_str[100];
2130+
char *dest_addr, *tx_id, privkey_str[70];
21322131
int64_t amount = 0, gas = 0, gas_price = 0, broadcast = 0;
21332132
bits256 privkey;
21342133

@@ -2159,14 +2158,14 @@ char *LP_eth_withdraw(struct iguana_info *coin,cJSON *argjson)
21592158
}
21602159

21612160
broadcast = jint(argjson, "broadcast");
2162-
satoshisToWei(amount_str, amount);
2161+
extern void *LP_eth_client;
21632162
if (broadcast == 1) {
21642163
privkey = LP_privkey(coin->symbol, coin->smartaddr, coin->taddr);
21652164
uint8arrayToHex(privkey_str, privkey.bytes, 32);
21662165
if (strcmp(coin->symbol, "ETH") == 0) {
2167-
tx_id = sendEth(dest_addr, amount_str, privkey_str, 0, gas, gas_price, 0);
2166+
tx_id = send_eth(dest_addr, amount, gas, gas_price, 0, LP_eth_client);
21682167
} else {
2169-
tx_id = sendErc20(coin->etomic, dest_addr, amount_str, privkey_str, 0, gas, gas_price, 0, coin->decimals);
2168+
tx_id = send_erc20(coin->etomic, dest_addr, amount, gas, gas_price, 0, coin->decimals, LP_eth_client);
21702169
}
21712170
if (tx_id != NULL) {
21722171
jaddstr(retjson, "tx_id", tx_id);
@@ -2176,7 +2175,7 @@ char *LP_eth_withdraw(struct iguana_info *coin,cJSON *argjson)
21762175
}
21772176
return (jprint(retjson, 1));
21782177
} else {
2179-
return LP_eth_tx_fee(coin, dest_addr, amount_str, gas, gas_price);
2178+
return LP_eth_tx_fee(coin, dest_addr, (uint64_t)amount, gas, gas_price);
21802179
}
21812180
}
21822181

Diff for: iguana/exchanges/etomicswap/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,4 @@ ethabi = { git = "https://github.com/artemii235/ethabi" }
1717
hex = "0.3.2"
1818
regex = "1"
1919
libc = "0.2.42"
20+
unwrap = "1.2.0"

0 commit comments

Comments
 (0)