Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 480
Bump electrum_client dependency and add new TLS-backend features #3587
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
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -19,23 +19,32 @@ time = [] | ||
| esplora-async = ["async-interface", "esplora-client/async", "esplora-client/tokio", "futures"] | ||
| esplora-async-https = ["esplora-async", "esplora-client/async-https-rustls"] | ||
| esplora-blocking = ["esplora-client/blocking"] | ||
| electrum = ["electrum-client"] | ||
| async-interface = [] | ||
| # dummy feature to enable the common codepaths for electrum | ||
| _electrum = [] | ||
| # the 'default' electrum feature, enabling `rustls` with the `aws-lc-rs` crypto provider | ||
| electrum = ["_electrum", "electrum-client/use-rustls"] | ||
| electrum-rustls = ["electrum"] | ||
| # this feature enables `rustls` with the `ring` crypto provider | ||
| electrum-rustls-ring = ["_electrum", "electrum-client/use-rustls-ring"] | ||
| [dependencies] | ||
| lightning = { version = "0.2.0", path = "../lightning", default-features = false, features = ["std"] } | ||
| lightning-macros = { version = "0.2", path = "../lightning-macros", default-features = false } | ||
| bitcoin = { version = "0.32.2", default-features = false } | ||
| futures = { version = "0.3", optional = true } | ||
| esplora-client = { version = "0.11", default-features = false, optional = true } | ||
| electrum-client = { version = "0.21.0", optional = true } | ||
| electrum-client = { version = "0.22.0", optional = true, default-features = false, features = ["proxy"] } | ||
tnull marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| [dev-dependencies] | ||
| lightning = { version = "0.2.0", path = "../lightning", default-features = false, features = ["std", "_test_utils"] } | ||
| tokio = { version = "1.35.0", features = ["macros"] } | ||
| [target.'cfg(not(target_os = "windows"))'.dev-dependencies] | ||
| electrsd = { version = "0.28.0", default-features = false, features = ["legacy"] } | ||
| electrsd = { version = "0.33.0", default-features = false, features = ["legacy"] } | ||
| corepc-node = { version = "0.7.0", default-features = false, features = ["28_0"] } | ||
| [lints.rust.unexpected_cfgs] | ||
| level = "forbid" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,12 @@ | ||
| #![cfg(all( | ||
| not(target_os = "windows"), | ||
| any(feature = "esplora-blocking", feature = "esplora-async", feature = "electrum") | ||
| any(feature = "esplora-blocking", feature = "esplora-async", feature = "_electrum") | ||
| ))] | ||
| use lightning::chain::transaction::{OutPoint, TransactionData}; | ||
| use lightning::chain::{Confirm, Filter, WatchedOutput}; | ||
| use lightning::util::test_utils::TestLogger; | ||
| #[cfg(feature = "electrum")] | ||
| #[cfg(feature = "_electrum")] | ||
| use lightning_transaction_sync::ElectrumSyncClient; | ||
| #[cfg(any(feature = "esplora-blocking", feature = "esplora-async"))] | ||
| use lightning_transaction_sync::EsploraSyncClient; | ||
| @@ -17,9 +17,9 @@ use bitcoin::block::Header; | ||
| use bitcoin::constants::genesis_block; | ||
| use bitcoin::network::Network; | ||
| use bitcoin::{Amount, BlockHash, Txid}; | ||
| use bitcoind::bitcoincore_rpc::RpcApi; | ||
| use electrsd::bitcoind::bitcoincore_rpc::bitcoincore_rpc_json::AddressType; | ||
| use electrsd::{bitcoind, bitcoind::BitcoinD, ElectrsD}; | ||
| use electrsd::corepc_node::Node as BitcoinD; | ||
| use electrsd::{corepc_node, ElectrsD}; | ||
| use std::collections::{HashMap, HashSet}; | ||
| use std::env; | ||
| @@ -28,10 +28,10 @@ use std::time::Duration; | ||
| pub fn setup_bitcoind_and_electrsd() -> (BitcoinD, ElectrsD) { | ||
| let bitcoind_exe = | ||
| env::var("BITCOIND_EXE").ok().or_else(|| bitcoind::downloaded_exe_path().ok()).expect( | ||
| env::var("BITCOIND_EXE").ok().or_else(|| corepc_node::downloaded_exe_path().ok()).expect( | ||
| "you need to provide an env var BITCOIND_EXE or specify a bitcoind version feature", | ||
| ); | ||
| let mut bitcoind_conf = bitcoind::Conf::default(); | ||
| let mut bitcoind_conf = corepc_node::Conf::default(); | ||
| bitcoind_conf.network = "regtest"; | ||
| let bitcoind = BitcoinD::with_conf(bitcoind_exe, &bitcoind_conf).unwrap(); | ||
| @@ -47,14 +47,15 @@ pub fn setup_bitcoind_and_electrsd() -> (BitcoinD, ElectrsD) { | ||
| } | ||
| pub fn generate_blocks_and_wait(bitcoind: &BitcoinD, electrsd: &ElectrsD, num: usize) { | ||
| let cur_height = bitcoind.client.get_block_count().expect("failed to get current block height"); | ||
| let address = bitcoind | ||
| let cur_height = bitcoind | ||
| .client | ||
| .get_new_address(Some("test"), Some(AddressType::Legacy)) | ||
| .expect("failed to get new address") | ||
| .assume_checked(); | ||
| .get_block_count() | ||
| .expect("failed to get current block height") | ||
| .into_model() | ||
| .0; | ||
| let address = bitcoind.client.new_address().expect("failed to get new address"); | ||
| // TODO: expect this Result once the WouldBlock issue is resolved upstream. | ||
| let _block_hashes_res = bitcoind.client.generate_to_address(num as u64, &address); | ||
| let _block_hashes_res = bitcoind.client.generate_to_address(num, &address); | ||
| wait_for_block(electrsd, cur_height as usize + num); | ||
| } | ||
| @@ -175,36 +176,20 @@ macro_rules! test_syncing { | ||
| assert_eq!(events.len(), 1); | ||
| // Check registered confirmed transactions are marked confirmed | ||
| let new_address = $bitcoind | ||
| .client | ||
| .get_new_address(Some("test"), Some(AddressType::Legacy)) | ||
| .unwrap() | ||
| .assume_checked(); | ||
| let new_address = $bitcoind.client.new_address().unwrap(); | ||
| let txid = $bitcoind | ||
| .client | ||
| .send_to_address( | ||
| &new_address, | ||
| Amount::from_sat(5000), | ||
| None, | ||
| None, | ||
| None, | ||
| None, | ||
| None, | ||
| None, | ||
| ) | ||
| .send_to_address(&new_address, Amount::from_sat(5000)) | ||
| .unwrap() | ||
| .0 | ||
| .parse() | ||
| .unwrap(); | ||
| let second_txid = $bitcoind | ||
| .client | ||
| .send_to_address( | ||
| &new_address, | ||
| Amount::from_sat(5000), | ||
| None, | ||
| None, | ||
| None, | ||
| None, | ||
| None, | ||
| None, | ||
| ) | ||
| .send_to_address(&new_address, Amount::from_sat(5000)) | ||
| .unwrap() | ||
| .0 | ||
| .parse() | ||
| .unwrap(); | ||
| $tx_sync.register_tx(&txid, &new_address.script_pubkey()); | ||
| @@ -224,16 +209,12 @@ macro_rules! test_syncing { | ||
| assert!($confirmable.unconfirmed_txs.lock().unwrap().is_empty()); | ||
| // Now take an arbitrary output of the second transaction and check we'll confirm its spend. | ||
| let tx_res = $bitcoind.client.get_transaction(&second_txid, None).unwrap(); | ||
| let block_hash = tx_res.info.blockhash.unwrap(); | ||
| let tx = tx_res.transaction().unwrap(); | ||
| let tx_res = $bitcoind.client.get_transaction(second_txid).unwrap().into_model().unwrap(); | ||
| let block_hash = tx_res.block_hash.unwrap(); | ||
| let tx = tx_res.tx; | ||
| let prev_outpoint = tx.input.first().unwrap().previous_output; | ||
| let prev_tx = $bitcoind | ||
| .client | ||
| .get_transaction(&prev_outpoint.txid, None) | ||
| .unwrap() | ||
| .transaction() | ||
| .unwrap(); | ||
| let prev_tx = | ||
| $bitcoind.client.get_transaction(prev_outpoint.txid).unwrap().into_model().unwrap().tx; | ||
| let prev_script_pubkey = prev_tx.output[prev_outpoint.vout as usize].script_pubkey.clone(); | ||
| let output = WatchedOutput { | ||
| block_hash: Some(block_hash), | ||
| @@ -251,19 +232,26 @@ macro_rules! test_syncing { | ||
| assert!($confirmable.unconfirmed_txs.lock().unwrap().is_empty()); | ||
| // Check previously confirmed transactions are marked unconfirmed when they are reorged. | ||
| let best_block_hash = $bitcoind.client.get_best_block_hash().unwrap(); | ||
| $bitcoind.client.invalidate_block(&best_block_hash).unwrap(); | ||
| let best_block_hash = | ||
| $bitcoind.client.get_best_block_hash().unwrap().into_model().unwrap().0; | ||
| $bitcoind.client.invalidate_block(best_block_hash).unwrap(); | ||
| // We're getting back to the previous height with a new tip, but best block shouldn't change. | ||
| generate_blocks_and_wait(&$bitcoind, &$electrsd, 1); | ||
| assert_ne!($bitcoind.client.get_best_block_hash().unwrap(), best_block_hash); | ||
| assert_ne!( | ||
| $bitcoind.client.get_best_block_hash().unwrap().into_model().unwrap().0, | ||
| best_block_hash | ||
| ); | ||
| maybe_await!($tx_sync.sync(vec![&$confirmable])).unwrap(); | ||
| let events = std::mem::take(&mut *$confirmable.events.lock().unwrap()); | ||
| assert_eq!(events.len(), 0); | ||
| // Now we're surpassing previous height, getting new tip. | ||
| generate_blocks_and_wait(&$bitcoind, &$electrsd, 1); | ||
| assert_ne!($bitcoind.client.get_best_block_hash().unwrap(), best_block_hash); | ||
| assert_ne!( | ||
| $bitcoind.client.get_best_block_hash().unwrap().into_model().unwrap().0, | ||
tnull marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| best_block_hash | ||
| ); | ||
| maybe_await!($tx_sync.sync(vec![&$confirmable])).unwrap(); | ||
| // Transactions still confirmed but under new tip. | ||
| @@ -344,7 +332,7 @@ async fn test_esplora_syncs() { | ||
| } | ||
| #[test] | ||
| #[cfg(feature = "electrum")] | ||
| #[cfg(feature = "_electrum")] | ||
| fn test_electrum_syncs() { | ||
| let (bitcoind, electrsd) = setup_bitcoind_and_electrsd(); | ||
| generate_blocks_and_wait(&bitcoind, &electrsd, 101); | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.