Skip to content

Commit 91b0f0b

Browse files
Update crates/electrum to bitcoin 0.30.0
1 parent f4e3ba3 commit 91b0f0b

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

crates/electrum/Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ readme = "README.md"
1313

1414
[dependencies]
1515
bdk_chain = { path = "../chain", version = "0.5.0", features = ["serde", "miniscript"] }
16-
electrum-client = { version = "0.12" }
16+
electrum-client = { version = "0.17" }
17+
#rustls = { version = "=0.21.1", optional = true, features = ["dangerous_configuration"] }

crates/electrum/src/electrum_ext.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use bdk_chain::{
2-
bitcoin::{hashes::hex::FromHex, OutPoint, Script, Transaction, Txid},
2+
bitcoin::{OutPoint, ScriptBuf, Transaction, Txid},
33
keychain::LocalUpdate,
44
local_chain::{self, CheckPoint},
55
tx_graph::{self, TxGraph},
@@ -9,6 +9,7 @@ use electrum_client::{Client, ElectrumApi, Error, HeaderNotification};
99
use std::{
1010
collections::{BTreeMap, BTreeSet, HashMap, HashSet},
1111
fmt::Debug,
12+
str::FromStr,
1213
};
1314

1415
/// We assume that a block of this depth and deeper cannot be reorged.
@@ -167,7 +168,7 @@ pub trait ElectrumExt<A> {
167168
fn scan<K: Ord + Clone>(
168169
&self,
169170
prev_tip: Option<CheckPoint>,
170-
keychain_spks: BTreeMap<K, impl IntoIterator<Item = (u32, Script)>>,
171+
keychain_spks: BTreeMap<K, impl IntoIterator<Item = (u32, ScriptBuf)>>,
171172
txids: impl IntoIterator<Item = Txid>,
172173
outpoints: impl IntoIterator<Item = OutPoint>,
173174
stop_gap: usize,
@@ -180,7 +181,7 @@ pub trait ElectrumExt<A> {
180181
fn scan_without_keychain(
181182
&self,
182183
prev_tip: Option<CheckPoint>,
183-
misc_spks: impl IntoIterator<Item = Script>,
184+
misc_spks: impl IntoIterator<Item = ScriptBuf>,
184185
txids: impl IntoIterator<Item = Txid>,
185186
outpoints: impl IntoIterator<Item = OutPoint>,
186187
batch_size: usize,
@@ -205,7 +206,7 @@ impl ElectrumExt<ConfirmationHeightAnchor> for Client {
205206
fn scan<K: Ord + Clone>(
206207
&self,
207208
prev_tip: Option<CheckPoint>,
208-
keychain_spks: BTreeMap<K, impl IntoIterator<Item = (u32, Script)>>,
209+
keychain_spks: BTreeMap<K, impl IntoIterator<Item = (u32, ScriptBuf)>>,
209210
txids: impl IntoIterator<Item = Txid>,
210211
outpoints: impl IntoIterator<Item = OutPoint>,
211212
stop_gap: usize,
@@ -215,7 +216,7 @@ impl ElectrumExt<ConfirmationHeightAnchor> for Client {
215216
.into_iter()
216217
.map(|(k, s)| (k, s.into_iter()))
217218
.collect::<BTreeMap<K, _>>();
218-
let mut scanned_spks = BTreeMap::<(K, u32), (Script, bool)>::new();
219+
let mut scanned_spks = BTreeMap::<(K, u32), (ScriptBuf, bool)>::new();
219220

220221
let txids = txids.into_iter().collect::<Vec<_>>();
221222
let outpoints = outpoints.into_iter().collect::<Vec<_>>();
@@ -375,7 +376,7 @@ fn determine_tx_anchor(
375376
// transactions residing in the genesis block to have height 0, then interpret a height of 0 as
376377
// unconfirmed for all other transactions.
377378
if txid
378-
== Txid::from_hex("4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b")
379+
== Txid::from_str("4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b")
379380
.expect("must deserialize genesis coinbase txid")
380381
{
381382
let anchor_block = cps.values().next()?.block_id();
@@ -506,10 +507,10 @@ fn populate_with_spks<K, I: Ord + Clone>(
506507
client: &Client,
507508
cps: &BTreeMap<u32, CheckPoint>,
508509
update: &mut ElectrumUpdate<K, ConfirmationHeightAnchor>,
509-
spks: &mut impl Iterator<Item = (I, Script)>,
510+
spks: &mut impl Iterator<Item = (I, ScriptBuf)>,
510511
stop_gap: usize,
511512
batch_size: usize,
512-
) -> Result<BTreeMap<I, (Script, bool)>, Error> {
513+
) -> Result<BTreeMap<I, (ScriptBuf, bool)>, Error> {
513514
let mut unused_spk_count = 0_usize;
514515
let mut scanned_spks = BTreeMap::new();
515516

@@ -521,7 +522,8 @@ fn populate_with_spks<K, I: Ord + Clone>(
521522
return Ok(scanned_spks);
522523
}
523524

524-
let spk_histories = client.batch_script_get_history(spks.iter().map(|(_, s)| s))?;
525+
let spk_histories =
526+
client.batch_script_get_history(spks.iter().map(|(_, s)| s.as_script()))?;
525527

526528
for ((spk_index, spk), spk_history) in spks.into_iter().zip(spk_histories) {
527529
if spk_history.is_empty() {

0 commit comments

Comments
 (0)