mirror of
https://github.com/comit-network/xmr-btc-swap.git
synced 2025-12-10 22:35:45 -05:00
Merge #359
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 /> [](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:
commit
7397cb5990
3 changed files with 20 additions and 29 deletions
|
|
@ -3,10 +3,10 @@ use crate::bitcoin::{Address, Amount, Transaction};
|
|||
use crate::env;
|
||||
use ::bitcoin::util::psbt::PartiallySignedTransaction;
|
||||
use ::bitcoin::Txid;
|
||||
use anyhow::{anyhow, bail, Context, Result};
|
||||
use anyhow::{bail, Context, Result};
|
||||
use bdk::blockchain::{noop_progress, Blockchain, ElectrumBlockchain};
|
||||
use bdk::descriptor::Segwitv0;
|
||||
use bdk::electrum_client::{self, ElectrumApi, GetHistoryRes};
|
||||
use bdk::electrum_client::{ElectrumApi, GetHistoryRes};
|
||||
use bdk::keys::DerivableKey;
|
||||
use bdk::{FeeRate, KeychainKind};
|
||||
use bitcoin::Script;
|
||||
|
|
@ -35,12 +35,8 @@ impl Wallet {
|
|||
key: impl DerivableKey<Segwitv0> + Clone,
|
||||
env_config: env::Config,
|
||||
) -> Result<Self> {
|
||||
// Workaround for https://github.com/bitcoindevkit/rust-electrum-client/issues/47.
|
||||
let config = electrum_client::ConfigBuilder::default().retry(2).build();
|
||||
|
||||
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 client = bdk::electrum_client::Client::new(electrum_rpc_url.as_str())
|
||||
.context("Failed to initialize Electrum RPC client")?;
|
||||
|
||||
let db = bdk::sled::open(wallet_dir)?.open_tree(SLED_TREE_NAME)?;
|
||||
|
||||
|
|
@ -52,8 +48,8 @@ impl Wallet {
|
|||
ElectrumBlockchain::from(client),
|
||||
)?;
|
||||
|
||||
let electrum = bdk::electrum_client::Client::from_config(electrum_rpc_url.as_str(), config)
|
||||
.map_err(|e| anyhow!("Failed to init electrum rpc client {:?}", e))?;
|
||||
let electrum = bdk::electrum_client::Client::new(electrum_rpc_url.as_str())
|
||||
.context("Failed to initialize Electrum RPC client")?;
|
||||
|
||||
Ok(Self {
|
||||
wallet: Arc::new(Mutex::new(bdk_wallet)),
|
||||
|
|
@ -101,9 +97,7 @@ impl Wallet {
|
|||
.list_transactions(true)?
|
||||
.iter()
|
||||
.find(|tx| tx.txid == txid)
|
||||
.ok_or_else(|| {
|
||||
anyhow!("Could not find tx in bdk wallet when trying to determine fees")
|
||||
})?
|
||||
.context("Could not find tx in bdk wallet when trying to determine fees")?
|
||||
.fees;
|
||||
|
||||
Ok(Amount::from_sat(fees))
|
||||
|
|
@ -205,7 +199,7 @@ impl Wallet {
|
|||
pub async fn get_raw_transaction(&self, txid: Txid) -> Result<Transaction> {
|
||||
self.get_tx(txid)
|
||||
.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>
|
||||
|
|
@ -313,12 +307,9 @@ struct Client {
|
|||
|
||||
impl Client {
|
||||
fn new(electrum: bdk::electrum_client::Client, interval: Duration) -> Result<Self> {
|
||||
let latest_block = electrum.block_headers_subscribe().map_err(|e| {
|
||||
anyhow!(
|
||||
"Electrum client failed to subscribe to header notifications: {:?}",
|
||||
e
|
||||
)
|
||||
})?;
|
||||
let latest_block = electrum
|
||||
.block_headers_subscribe()
|
||||
.context("Failed to subscribe to header notifications")?;
|
||||
|
||||
Ok(Self {
|
||||
electrum,
|
||||
|
|
@ -409,7 +400,7 @@ impl Client {
|
|||
let latest_block = std::iter::from_fn(|| self.electrum.block_headers_pop().transpose())
|
||||
.last()
|
||||
.transpose()
|
||||
.map_err(|e| anyhow!("Failed to pop header notification: {:?}", e))?;
|
||||
.context("Failed to pop header notification")?;
|
||||
|
||||
if let Some(new_block) = latest_block {
|
||||
tracing::debug!(
|
||||
|
|
@ -426,7 +417,7 @@ impl Client {
|
|||
let histories = self
|
||||
.electrum
|
||||
.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() {
|
||||
bail!(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue