Upgrade to bdk 0.10

This fixes #546. I don't know why, but I can't reproduce the problem
with the updated dependency.
pull/643/head
Thomas Eizinger 3 years ago
parent 475057abda
commit 0296509110
No known key found for this signature in database
GPG Key ID: 651AC83A6C6C8B96

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Fixed
- An occasional error where users couldn't start a swap because of `InsufficientFunds` that were off by exactly 1 satoshi.
## [0.8.0] - 2021-07-09 ## [0.8.0] - 2021-07-09
### Added ### Added

19
Cargo.lock generated

@ -235,11 +235,20 @@ version = "0.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd"
[[package]]
name = "base64-compat"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a8d4d2746f89841e49230dd26917df1876050f95abafafbe34f47cb534b88d7"
dependencies = [
"byteorder",
]
[[package]] [[package]]
name = "bdk" name = "bdk"
version = "0.8.0" version = "0.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05d7fee1aedf8935ba1e2c9aeee640d1b9754da1b64f30ad47e8b8e2b7904ec0" checksum = "8f4da304c23a06c21807598a7fe3223566e84c76c6bba2cab2504370dd6f4938"
dependencies = [ dependencies = [
"async-trait", "async-trait",
"bdk-macros", "bdk-macros",
@ -252,14 +261,13 @@ dependencies = [
"serde", "serde",
"serde_json", "serde_json",
"sled", "sled",
"tokio",
] ]
[[package]] [[package]]
name = "bdk-macros" name = "bdk-macros"
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 = "b45570b78250774145859a8f85bfdb6e310663fc82640d7e159a44b1386074a2" checksum = "c3f510015e946c5995cc169f7ed4c92ba032bbce795c0956ee0d98d82f7aff78"
dependencies = [ dependencies = [
"proc-macro2 1.0.27", "proc-macro2 1.0.27",
"quote 1.0.9", "quote 1.0.9",
@ -331,6 +339,7 @@ version = "0.26.2"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6742ec672d3f12506f4ac5c0d853926ff1f94e675f60ffd3224039972bf663f1" checksum = "6742ec672d3f12506f4ac5c0d853926ff1f94e675f60ffd3224039972bf663f1"
dependencies = [ dependencies = [
"base64-compat",
"bech32", "bech32",
"bitcoin_hashes", "bitcoin_hashes",
"secp256k1", "secp256k1",

@ -15,7 +15,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 = "0.8" bdk = "0.10"
big-bytes = "1" big-bytes = "1"
bitcoin = { version = "0.26", features = [ "rand", "use-serde" ] } bitcoin = { version = "0.26", features = [ "rand", "use-serde" ] }
bmrng = "0.5" bmrng = "0.5"

@ -306,7 +306,8 @@ where
.iter() .iter()
.find(|tx| tx.txid == txid) .find(|tx| tx.txid == txid)
.context("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; .fee
.expect("fees are always present with Electrum backend");
Ok(Amount::from_sat(fees)) Ok(Amount::from_sat(fees))
} }
@ -394,14 +395,16 @@ where
let mut tx_builder = wallet.build_tx(); let mut tx_builder = wallet.build_tx();
let dummy_script = Script::from(vec![0u8; locking_script_size]); let dummy_script = Script::from(vec![0u8; locking_script_size]);
tx_builder.set_single_recipient(dummy_script); tx_builder.drain_to(dummy_script);
tx_builder.drain_wallet();
tx_builder.fee_rate(fee_rate); tx_builder.fee_rate(fee_rate);
let response = tx_builder.finish(); let response = tx_builder.finish();
match response { match response {
Ok((_, details)) => { Ok((_, details)) => {
let max_giveable = details.sent - details.fees; let max_giveable = details.sent
- details
.fee
.expect("fees are always present with Electrum backend");
Ok(Amount::from_sat(max_giveable)) Ok(Amount::from_sat(max_giveable))
} }
Err(bdk::Error::InsufficientFunds { .. }) => Ok(Amount::ZERO), Err(bdk::Error::InsufficientFunds { .. }) => Ok(Amount::ZERO),
@ -600,7 +603,7 @@ impl WalletBuilder {
pub fn build(self) -> Wallet<(), bdk::database::MemoryDatabase, StaticFeeRate> { pub fn build(self) -> Wallet<(), bdk::database::MemoryDatabase, StaticFeeRate> {
use bdk::database::MemoryDatabase; use bdk::database::MemoryDatabase;
use bdk::{LocalUtxo, TransactionDetails}; use bdk::{ConfirmationTime, LocalUtxo, TransactionDetails};
use bitcoin::OutPoint; use bitcoin::OutPoint;
use testutils::testutils; use testutils::testutils;

Loading…
Cancel
Save