Skip to content
Merged
Show file tree
Hide file tree
Changes from 39 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
94e6df2
fix some ignored tests
shamardy Sep 15, 2022
92bd009
move connect_to_lightning_node to rpc_command
shamardy Sep 15, 2022
e18b4aa
move open_channel to rpc_command
shamardy Sep 15, 2022
a16cbbe
move update_channel to rpc_command
shamardy Sep 16, 2022
df6ae9b
move list channels rpcs to rpc_command
shamardy Sep 16, 2022
48d748e
move get_channel_details, get_claimable_balances, trusted nodes rpcs …
shamardy Sep 16, 2022
26806be
move close_channel to rpc_command
shamardy Sep 16, 2022
3732050
move get_payment_details, list_payments_by_filter to rpc_command
shamardy Sep 16, 2022
2322b25
move send_payment to rpc_command
shamardy Sep 16, 2022
b638bb7
move the rest of lightning RPCs to rpc_command, use lightning:: prefi…
shamardy Sep 16, 2022
abfb9a8
edit SwapMsg MakerPayment and TakerPayment to allow sending payment i…
shamardy Sep 21, 2022
d93b834
create_invoice_for_hash fn, impl other_side_instructions for Lightnin…
shamardy Sep 22, 2022
62d5a9a
check connection to nodes before generating route hints, refactors
shamardy Sep 23, 2022
3bb77df
fix TakerFee msg to include PaymentDataMsg (lightning invoice to be p…
shamardy Sep 27, 2022
5f2b459
Merge remote-tracking branch 'origin/dev' into lightning-swaps-poc
shamardy Sep 27, 2022
a436358
Validate invoice received from swap messages wip
shamardy Sep 28, 2022
a7af8c4
Validate invoice on maker side if maker is lightning coin
shamardy Sep 29, 2022
ba8dfc8
Merge remote-tracking branch 'origin/dev' into lightning-swaps-poc
shamardy Sep 29, 2022
9e67c41
add optional PaymentInstructions parameter to send_maker_payment, sen…
shamardy Sep 29, 2022
2a94c23
implement send_taker_payment and send_maker_payment for LightningCoin
shamardy Sep 30, 2022
ac6b7a9
change tx_enum_from_bytes to return none for lightning coin
shamardy Oct 3, 2022
e8ce302
Some refactors and rollbacks
shamardy Oct 4, 2022
474b0a6
impl more swap methods, do a unit test swap where taker is lightning
shamardy Oct 6, 2022
2f99e1b
refactor some code by adding payment_hash_from_slice fn
shamardy Oct 7, 2022
38e9049
minor fixes and added more todo for next PR/s
shamardy Oct 7, 2022
03aa40d
refactor lightning taker swap test
shamardy Oct 10, 2022
9ccada1
more refactors, broadcast_p2p_tx_msg shouldn't work with lightning pa…
shamardy Oct 10, 2022
f108dfc
add preimage of swap payment to DB after the secret is revealed (clai…
shamardy Oct 10, 2022
6d622f6
wip
shamardy Oct 11, 2022
a4e970c
Final refactors
shamardy Oct 11, 2022
7fa7042
Merge remote-tracking branch 'origin/dev' into lightning-swaps-poc
shamardy Oct 11, 2022
d2f8158
Review fixes: better names for some functions/structs
shamardy Oct 12, 2022
60acd0a
Review fixes: some errors fixes, add channels::, nodes::, payments:: …
shamardy Oct 13, 2022
24dd76a
Review fixes: fix some error handling issues
shamardy Oct 14, 2022
c49f7ea
more review fixes
shamardy Oct 18, 2022
dc4b6ca
Merge remote-tracking branch 'origin/dev' into lightning-swaps-poc
shamardy Oct 18, 2022
8b515c8
review fixes wip: rename SwapTxDataMsg enum variants
shamardy Oct 24, 2022
68765b8
review fixes wip: validate_instructions to return an error instead of…
shamardy Oct 24, 2022
2113b7a
Review fixes: make TransactionIdentifier::tx_hex not an Option and ad…
shamardy Oct 24, 2022
ab4ab00
Merge remote-tracking branch 'origin/dev' into lightning-swaps-poc
shamardy Oct 26, 2022
0f53219
Merge remote-tracking branch 'origin/dev' into lightning-swaps-poc
shamardy Oct 26, 2022
bea9173
re-add Todo that was removed by merge
shamardy Oct 26, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 30 additions & 9 deletions mm2src/coins/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ use web3_transport::{EthFeeHistoryNamespace, Web3Transport, Web3TransportNode};
use super::{coin_conf, AsyncMutex, BalanceError, BalanceFut, CoinBalance, CoinFutSpawner, CoinProtocol,
CoinTransportMetrics, CoinsContext, FeeApproxStage, FoundSwapTxSpend, HistorySyncState, MarketCoinOps,
MmCoin, MyAddressError, NegotiateSwapContractAddrErr, NumConversError, NumConversResult,
RawTransactionError, RawTransactionFut, RawTransactionRequest, RawTransactionRes, RawTransactionResult,
RpcClientType, RpcTransportEventHandler, RpcTransportEventHandlerShared, SearchForSwapTxSpendInput,
SignatureError, SignatureResult, SwapOps, TradeFee, TradePreimageError, TradePreimageFut,
TradePreimageResult, TradePreimageValue, Transaction, TransactionDetails, TransactionEnum, TransactionErr,
TransactionFut, TxMarshalingErr, UnexpectedDerivationMethod, ValidateAddressResult,
ValidateOtherPubKeyErr, ValidatePaymentError, ValidatePaymentFut, ValidatePaymentInput, VerificationError,
VerificationResult, WatcherValidatePaymentInput, WithdrawError, WithdrawFee, WithdrawFut, WithdrawRequest,
WithdrawResult};
PaymentInstructions, PaymentInstructionsErr, RawTransactionError, RawTransactionFut,
RawTransactionRequest, RawTransactionRes, RawTransactionResult, RpcClientType, RpcTransportEventHandler,
RpcTransportEventHandlerShared, SearchForSwapTxSpendInput, SignatureError, SignatureResult, SwapOps,
TradeFee, TradePreimageError, TradePreimageFut, TradePreimageResult, TradePreimageValue, Transaction,
TransactionDetails, TransactionEnum, TransactionErr, TransactionFut, TxMarshalingErr,
UnexpectedDerivationMethod, ValidateAddressResult, ValidateInstructionsErr, ValidateOtherPubKeyErr,
ValidatePaymentError, ValidatePaymentFut, ValidatePaymentInput, VerificationError, VerificationResult,
WatcherValidatePaymentInput, WithdrawError, WithdrawFee, WithdrawFut, WithdrawRequest, WithdrawResult};

pub use rlp;

Expand Down Expand Up @@ -735,6 +735,7 @@ impl SwapOps for EthCoin {
amount: BigDecimal,
swap_contract_address: &Option<BytesJson>,
_swap_unique_data: &[u8],
_payment_instructions: &Option<PaymentInstructions>,
) -> TransactionFut {
let taker_addr = try_tx_fus!(addr_from_raw_pubkey(taker_pub));
let swap_contract_address = try_tx_fus!(swap_contract_address.try_to_address());
Expand All @@ -760,6 +761,7 @@ impl SwapOps for EthCoin {
amount: BigDecimal,
swap_contract_address: &Option<BytesJson>,
_swap_unique_data: &[u8],
_payment_instructions: &Option<PaymentInstructions>,
) -> TransactionFut {
let maker_addr = try_tx_fus!(addr_from_raw_pubkey(maker_pub));
let swap_contract_address = try_tx_fus!(swap_contract_address.try_to_address());
Expand Down Expand Up @@ -1099,7 +1101,7 @@ impl SwapOps for EthCoin {
.await
}

fn extract_secret(&self, _secret_hash: &[u8], spend_tx: &[u8]) -> Result<Vec<u8>, String> {
async fn extract_secret(&self, _secret_hash: &[u8], spend_tx: &[u8]) -> Result<Vec<u8>, String> {
let unverified: UnverifiedTransaction = try_s!(rlp::decode(spend_tx));
let function = try_s!(SWAP_CONTRACT.function("receiverSpend"));
let tokens = try_s!(function.decode_input(&unverified.data));
Expand Down Expand Up @@ -1151,6 +1153,25 @@ impl SwapOps for EthCoin {
};
Ok(())
}

async fn payment_instructions(
&self,
_secret_hash: &[u8],
_amount: &BigDecimal,
) -> Result<Option<Vec<u8>>, MmError<PaymentInstructionsErr>> {
Ok(None)
}

fn validate_instructions(
&self,
_instructions: &[u8],
_secret_hash: &[u8],
_amount: BigDecimal,
) -> Result<PaymentInstructions, MmError<ValidateInstructionsErr>> {
MmError::err(ValidateInstructionsErr::UnsupportedCoin(self.ticker().to_string()))
}

fn is_supported_by_watchers(&self) -> bool { false }
}

#[cfg_attr(test, mockable)]
Expand Down
4 changes: 3 additions & 1 deletion mm2src/coins/eth/eth_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ fn send_and_refund_erc20_payment() {
"0.001".parse().unwrap(),
&coin.swap_contract_address(),
&[],
&None,
)
.wait()
.unwrap();
Expand Down Expand Up @@ -325,6 +326,7 @@ fn send_and_refund_eth_payment() {
"0.001".parse().unwrap(),
&coin.swap_contract_address(),
&[],
&None,
)
.wait()
.unwrap();
Expand Down Expand Up @@ -1411,7 +1413,7 @@ fn test_eth_extract_secret() {
100, 189, 72, 74, 221, 144, 66, 170, 68, 121, 29, 105, 19, 194, 35, 245, 196, 131, 236, 29, 105, 101, 30,
];

let secret = coin.extract_secret(&[0u8; 20], tx_hex.as_slice());
let secret = block_on(coin.extract_secret(&[0u8; 20], tx_hex.as_slice()));
assert!(secret.is_ok());
let expect_secret = &[
168, 151, 11, 232, 224, 253, 63, 180, 26, 114, 23, 184, 27, 10, 161, 80, 178, 251, 73, 204, 80, 174, 97, 118,
Expand Down
1 change: 1 addition & 0 deletions mm2src/coins/eth/eth_wasm_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ async fn test_send() {
"0.001".parse().unwrap(),
&None,
&[],
&None,
)
.compat()
.await;
Expand Down
Loading