Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[r2r] lightning ordermatching wip + library updates and more unit tests #1655

Merged
merged 25 commits into from
Mar 10, 2023
Merged
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
3965444
add a unit test to test lightning taker getting swap preimage from th…
shamardy Jan 19, 2023
5c94a9f
update rust-lightning to v0.0.111 wip
shamardy Jan 24, 2023
12f265c
update rust-lightning to v0.0.113 wip
shamardy Jan 26, 2023
fe0189e
update uuid to v1.2.2, use uuid instead of rpc_channel_id for lightni…
shamardy Jan 30, 2023
0a9e017
add unit tests for mpp and claiming swaps on-chain
shamardy Feb 2, 2023
31737cf
Add channel confirmation details to rpc response
shamardy Feb 3, 2023
65655c7
add test_lightning_maker_swap_mpp
shamardy Feb 3, 2023
29536be
wip: use protocol info to not match with lightning orders if there ar…
shamardy Feb 7, 2023
f07a9d1
Merge remote-tracking branch 'origin/dev' into ln-onchain-swaps
shamardy Feb 8, 2023
dfa04f0
wip: add amount to protocol info route check
shamardy Feb 8, 2023
e64f422
wip: refactor lightning protocol info code
shamardy Feb 9, 2023
8fdba01
Add max_total_cltv_expiry_delta and final_cltv_expiry_delta to route …
shamardy Feb 10, 2023
155ff64
Fix funding_generated_in_block is Null in DB error when 0 conf is ena…
shamardy Feb 13, 2023
d7a0c34
remove some unneeded todos, write better todos
shamardy Feb 13, 2023
268f2c6
remove more todos
shamardy Feb 13, 2023
a88e3ea
review fixes: use bech32 0.9.1, return error instead of using expect …
shamardy Feb 17, 2023
9f3803e
review fixes: use macro to simplify code, sort by short_channel_id
shamardy Feb 21, 2023
d37b6cc
review fixes: add doc comments for uuid and channel_id
shamardy Feb 21, 2023
9577efc
Merge remote-tracking branch 'origin/dev' into ln-onchain-swaps
shamardy Feb 27, 2023
f7953a7
Fix channel was closed issue but closing transaction wasn't broadcast…
shamardy Mar 3, 2023
e683bea
fix issue in db when retrying to pay an invoice
shamardy Mar 3, 2023
da8d3ad
Merge remote-tracking branch 'origin/dev' into ln-onchain-swaps
shamardy Mar 6, 2023
f92d69a
move converting tx hex to bytes outside send transaction loop in Broa…
shamardy Mar 7, 2023
c5dd404
Merge remote-tracking branch 'origin/dev' into ln-onchain-swaps
shamardy Mar 7, 2023
0daed47
import uuid::Error as UuidError in my_swaps.rs
shamardy Mar 9, 2023
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
37 changes: 31 additions & 6 deletions mm2src/coins/lightning/ln_platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -601,15 +601,40 @@ impl BroadcasterInterface for Platform {
let tx_hex = serialize_hex(tx);
debug!("Trying to broadcast transaction: {}", tx_hex);

let fut = self.coin.send_raw_tx(&tx_hex);
let platform_coin = self.coin.clone();
let fut = async move {
match fut.compat().await {
Ok(id) => info!("Transaction broadcasted successfully: {:?} ", id),
// TODO: broadcast transaction through p2p network in case of error
Err(e) => error!("Broadcast transaction {} failed: {}", txid, e),
loop {
let bytes = match hex::decode(&tx_hex) {
Ok(b) => b,
Err(e) => {
error!("Converting transaction to bytes error:{}", e);
break;
},
};

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can take this out of the loop, there's no need to repeat it in case of network failure

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

match platform_coin
.as_ref()
.rpc_client
.send_raw_transaction(bytes.into())
.compat()
.await
{
Ok(id) => {
info!("Transaction broadcasted successfully: {:?} ", id);
break;
},
// Todo: broadcast transaction through p2p network instead in case of error
// Todo: I don't want to rely on p2p broadcasting for now since there is no way to know if there are nodes running bitcoin in native mode or not
// Todo: Also we need to make sure that the transaction was broadcasted after relying on the p2p network
Err(e) => {
error!("Broadcast transaction {} failed: {}", txid, e);
if !e.get_inner().is_network_error() {
break;
}
Timer::sleep(TRY_LOOP_INTERVAL).await;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this loop repeat infinitely if the network error keeps coming?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes for now. When broadcasting transaction through p2p network is implemented, a loop to check if the transaction is on-chain or not can be added instead.

},
}
}
};

self.spawner().spawn(fut);
}
}
Expand Down