diff --git a/contrib/download_bitcoind_electrs.sh b/contrib/download_bitcoind_electrs.sh index 8b938a563d3..b279f7dcd19 100755 --- a/contrib/download_bitcoind_electrs.sh +++ b/contrib/download_bitcoind_electrs.sh @@ -10,17 +10,17 @@ HOST_PLATFORM="$(rustc --version --verbose | grep "host:" | awk '{ print $2 }')" ELECTRS_DL_ENDPOINT="https://github.com/RCasatta/electrsd/releases/download/electrs_releases" ELECTRS_VERSION="esplora_a33e97e1a1fc63fa9c20a116bb92579bbf43b254" BITCOIND_DL_ENDPOINT="https://bitcoincore.org/bin/" -BITCOIND_VERSION="25.1" +BITCOIND_VERSION="28.1" if [[ "$HOST_PLATFORM" == *linux* ]]; then ELECTRS_DL_FILE_NAME=electrs_linux_"$ELECTRS_VERSION".zip ELECTRS_DL_HASH="865e26a96e8df77df01d96f2f569dcf9622fc87a8d99a9b8fe30861a4db9ddf1" BITCOIND_DL_FILE_NAME=bitcoin-"$BITCOIND_VERSION"-x86_64-linux-gnu.tar.gz - BITCOIND_DL_HASH="a978c407b497a727f0444156e397b50491ce862d1f906fef9b521415b3611c8b" + BITCOIND_DL_HASH="07f77afd326639145b9ba9562912b2ad2ccec47b8a305bd075b4f4cb127b7ed7" elif [[ "$HOST_PLATFORM" == *darwin* ]]; then ELECTRS_DL_FILE_NAME=electrs_macos_"$ELECTRS_VERSION".zip ELECTRS_DL_HASH="2d5ff149e8a2482d3658e9b386830dfc40c8fbd7c175ca7cbac58240a9505bcd" BITCOIND_DL_FILE_NAME=bitcoin-"$BITCOIND_VERSION"-x86_64-apple-darwin.tar.gz - BITCOIND_DL_HASH="1acfde0ec3128381b83e3e5f54d1c7907871d324549129592144dd12a821eff1" + BITCOIND_DL_HASH="c85d1a0ebedeff43b99db2c906b50f14547b84175a4d0ebb039a9809789af280" else printf "\n\n" echo "Unsupported platform: $HOST_PLATFORM Exiting.." diff --git a/lightning-transaction-sync/Cargo.toml b/lightning-transaction-sync/Cargo.toml index 5e473d31266..e4a2d3cbb1a 100644 --- a/lightning-transaction-sync/Cargo.toml +++ b/lightning-transaction-sync/Cargo.toml @@ -28,14 +28,18 @@ lightning-macros = { version = "0.2", path = "../lightning-macros", default-feat 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 } [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.32.0", default-features = false, features = ["legacy"] } +#corepc-node = { version = "0.6.0", default-features = false, features = ["28_0"] } +electrsd = { git = "https://github.com/tnull/electrsd.git", branch = "2025-03-corepc-retry-pr", default-features = false, features = ["legacy"] } +corepc-node = { git = "https://github.com/tnull/corepc.git", branch = "2025-03-retry-initial-client-connections", default-features = false, features = ["28_0"] } + [lints.rust.unexpected_cfgs] level = "forbid" diff --git a/lightning-transaction-sync/tests/integration_tests.rs b/lightning-transaction-sync/tests/integration_tests.rs index 0a6f40b0972..1b6849955da 100644 --- a/lightning-transaction-sync/tests/integration_tests.rs +++ b/lightning-transaction-sync/tests/integration_tests.rs @@ -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, + best_block_hash + ); maybe_await!($tx_sync.sync(vec![&$confirmable])).unwrap(); // Transactions still confirmed but under new tip.