359: Bump bdk from 0.4.0 to 0.5.0 r=thomaseizinger a=dependabot[bot]

Bumps [bdk](https://github.com/bitcoindevkit/bdk) from 0.4.0 to 0.5.0.
<details>
<summary>Changelog</summary>
<p><em>Sourced from <a href="https://github.com/bitcoindevkit/bdk/blob/master/CHANGELOG.md">bdk's changelog</a>.</em></p>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="f7944e871b"><code>f7944e8</code></a> Bump version to 0.5.0</li>
<li><a href="2fea1761c1"><code>2fea176</code></a> Bump deps version</li>
<li><a href="fa27ae210f"><code>fa27ae2</code></a> Update version in lib.rs</li>
<li><a href="46fa41470e"><code>46fa414</code></a> Update CHANGELOG with the new release tag</li>
<li><a href="8ebe7f0ea5"><code>8ebe7f0</code></a> Merge commit 'refs/pull/308/head' of github.com:bitcoindevkit/bdk into releas...</li>
<li><a href="eb85390846"><code>eb85390</code></a> Merge commit 'refs/pull/309/head' of github.com:bitcoindevkit/bdk into releas...</li>
<li><a href="dc83db273a"><code>dc83db2</code></a> better derivation path building</li>
<li><a href="201bd6ee02"><code>201bd6e</code></a> better derivation path building</li>
<li><a href="396ffb42f9"><code>396ffb4</code></a> handle descriptor xkey origin</li>
<li><a href="9cf62ce874"><code>9cf62ce</code></a> [ci] Manually install libclang-common-10-dev to 'check-wasm' job</li>
<li>Additional commits viewable in <a href="https://github.com/bitcoindevkit/bdk/compare/v0.4.0...v0.5.0">compare view</a></li>
</ul>
</details>
<br />


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=bdk&package-manager=cargo&previous-version=0.4.0&new-version=0.5.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Thomas Eizinger <thomas@eizinger.io>
This commit is contained in:
bors[bot] 2021-03-24 06:12:52 +00:00 committed by GitHub
commit 7397cb5990
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 29 deletions

12
Cargo.lock generated
View File

@ -255,9 +255,9 @@ checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
[[package]] [[package]]
name = "bdk" name = "bdk"
version = "0.4.0" version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "daeccaea73c9fc27e218e2a4402070707fb8354afd30fecd4a1c9a0bea8b79c4" checksum = "4260e70501c2f9d6fb2915cf2be2f5b8ba57743e527834de5de6e371827f1e19"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"bdk-macros", "bdk-macros",
@ -275,9 +275,9 @@ dependencies = [
[[package]] [[package]]
name = "bdk-macros" name = "bdk-macros"
version = "0.3.0" version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b96757dbe9c7e0a8f0635c5366464d9c713528e111f47490e96385f70d6a67a6" checksum = "b45570b78250774145859a8f85bfdb6e310663fc82640d7e159a44b1386074a2"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -899,9 +899,9 @@ checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457"
[[package]] [[package]]
name = "electrum-client" name = "electrum-client"
version = "0.6.0" version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "21453800c95bb1aaa57490458c42d60c6277cb8a3e386030ec2381d5c2d4fa77" checksum = "4cab4d90cc575a7daab4cfed9e315912a88071bc47462e6be57516a2f01ccc89"
dependencies = [ dependencies = [
"bitcoin", "bitcoin",
"log", "log",

View File

@ -16,7 +16,7 @@ async-trait = "0.1"
atty = "0.2" atty = "0.2"
backoff = { version = "0.3", features = ["tokio"] } backoff = { version = "0.3", features = ["tokio"] }
base64 = "0.13" base64 = "0.13"
bdk = { version = "0.4" } bdk = { version = "0.5" }
big-bytes = "1" big-bytes = "1"
bitcoin = { version = "0.26", features = ["rand", "use-serde"] } bitcoin = { version = "0.26", features = ["rand", "use-serde"] }
config = { version = "0.11", default-features = false, features = ["toml"] } config = { version = "0.11", default-features = false, features = ["toml"] }

View File

@ -3,10 +3,10 @@ use crate::bitcoin::{Address, Amount, Transaction};
use crate::env; use crate::env;
use ::bitcoin::util::psbt::PartiallySignedTransaction; use ::bitcoin::util::psbt::PartiallySignedTransaction;
use ::bitcoin::Txid; use ::bitcoin::Txid;
use anyhow::{anyhow, bail, Context, Result}; use anyhow::{bail, Context, Result};
use bdk::blockchain::{noop_progress, Blockchain, ElectrumBlockchain}; use bdk::blockchain::{noop_progress, Blockchain, ElectrumBlockchain};
use bdk::descriptor::Segwitv0; use bdk::descriptor::Segwitv0;
use bdk::electrum_client::{self, ElectrumApi, GetHistoryRes}; use bdk::electrum_client::{ElectrumApi, GetHistoryRes};
use bdk::keys::DerivableKey; use bdk::keys::DerivableKey;
use bdk::{FeeRate, KeychainKind}; use bdk::{FeeRate, KeychainKind};
use bitcoin::Script; use bitcoin::Script;
@ -35,12 +35,8 @@ impl Wallet {
key: impl DerivableKey<Segwitv0> + Clone, key: impl DerivableKey<Segwitv0> + Clone,
env_config: env::Config, env_config: env::Config,
) -> Result<Self> { ) -> Result<Self> {
// Workaround for https://github.com/bitcoindevkit/rust-electrum-client/issues/47. let client = bdk::electrum_client::Client::new(electrum_rpc_url.as_str())
let config = electrum_client::ConfigBuilder::default().retry(2).build(); .context("Failed to initialize Electrum RPC client")?;
let client =
bdk::electrum_client::Client::from_config(electrum_rpc_url.as_str(), config.clone())
.map_err(|e| anyhow!("Failed to init electrum rpc client: {:?}", e))?;
let db = bdk::sled::open(wallet_dir)?.open_tree(SLED_TREE_NAME)?; let db = bdk::sled::open(wallet_dir)?.open_tree(SLED_TREE_NAME)?;
@ -52,8 +48,8 @@ impl Wallet {
ElectrumBlockchain::from(client), ElectrumBlockchain::from(client),
)?; )?;
let electrum = bdk::electrum_client::Client::from_config(electrum_rpc_url.as_str(), config) let electrum = bdk::electrum_client::Client::new(electrum_rpc_url.as_str())
.map_err(|e| anyhow!("Failed to init electrum rpc client {:?}", e))?; .context("Failed to initialize Electrum RPC client")?;
Ok(Self { Ok(Self {
wallet: Arc::new(Mutex::new(bdk_wallet)), wallet: Arc::new(Mutex::new(bdk_wallet)),
@ -101,9 +97,7 @@ impl Wallet {
.list_transactions(true)? .list_transactions(true)?
.iter() .iter()
.find(|tx| tx.txid == txid) .find(|tx| tx.txid == txid)
.ok_or_else(|| { .context("Could not find tx in bdk wallet when trying to determine fees")?
anyhow!("Could not find tx in bdk wallet when trying to determine fees")
})?
.fees; .fees;
Ok(Amount::from_sat(fees)) Ok(Amount::from_sat(fees))
@ -205,7 +199,7 @@ impl Wallet {
pub async fn get_raw_transaction(&self, txid: Txid) -> Result<Transaction> { pub async fn get_raw_transaction(&self, txid: Txid) -> Result<Transaction> {
self.get_tx(txid) self.get_tx(txid)
.await? .await?
.ok_or_else(|| anyhow!("Could not get raw tx with id: {}", txid)) .with_context(|| format!("Could not get raw tx with id: {}", txid))
} }
pub async fn status_of_script<T>(&self, tx: &T) -> Result<ScriptStatus> pub async fn status_of_script<T>(&self, tx: &T) -> Result<ScriptStatus>
@ -313,12 +307,9 @@ struct Client {
impl Client { impl Client {
fn new(electrum: bdk::electrum_client::Client, interval: Duration) -> Result<Self> { fn new(electrum: bdk::electrum_client::Client, interval: Duration) -> Result<Self> {
let latest_block = electrum.block_headers_subscribe().map_err(|e| { let latest_block = electrum
anyhow!( .block_headers_subscribe()
"Electrum client failed to subscribe to header notifications: {:?}", .context("Failed to subscribe to header notifications")?;
e
)
})?;
Ok(Self { Ok(Self {
electrum, electrum,
@ -409,7 +400,7 @@ impl Client {
let latest_block = std::iter::from_fn(|| self.electrum.block_headers_pop().transpose()) let latest_block = std::iter::from_fn(|| self.electrum.block_headers_pop().transpose())
.last() .last()
.transpose() .transpose()
.map_err(|e| anyhow!("Failed to pop header notification: {:?}", e))?; .context("Failed to pop header notification")?;
if let Some(new_block) = latest_block { if let Some(new_block) = latest_block {
tracing::debug!( tracing::debug!(
@ -426,7 +417,7 @@ impl Client {
let histories = self let histories = self
.electrum .electrum
.batch_script_get_history(self.script_history.keys()) .batch_script_get_history(self.script_history.keys())
.map_err(|e| anyhow!("Failed to get script histories {:?}", e))?; .context("Failed to get script histories")?;
if histories.len() != self.script_history.len() { if histories.len() != self.script_history.len() {
bail!( bail!(