From 9fd3939ea3817626f4b7f7a5ebad478b494e1df4 Mon Sep 17 00:00:00 2001 From: Steve Myers Date: Sun, 3 Mar 2024 18:11:12 -0600 Subject: [PATCH] docs(wallet): add warning on TxBuilder::allow_shrinking() and deprecate it test(wallet): add test_bump_fee_allow_shrinking test --- CHANGELOG.md | 9 ++++++++- src/wallet/mod.rs | 4 ++++ src/wallet/tx_builder.rs | 8 ++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4357dcb4..123db4347 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [v0.30.0] + +### Summary + +This maintenance release updates the project MSRV to 1.63.0 and deprecates `TxBuilder::allow_shrinking()`. + ## [v0.29.0] ### Summary @@ -693,4 +699,5 @@ final transaction is created by calling `finish` on the builder. [v0.28.1]: https://github.com/bitcoindevkit/bdk/compare/v0.28.0...v0.28.1 [v0.28.2]: https://github.com/bitcoindevkit/bdk/compare/v0.28.1...v0.28.2 [v0.29.0]: https://github.com/bitcoindevkit/bdk/compare/v0.28.2...v0.29.0 -[Unreleased]: https://github.com/bitcoindevkit/bdk/compare/v0.29.0...HEAD +[v0.30.0]: https://github.com/bitcoindevkit/bdk/compare/v0.29.0...v0.30.0 +[Unreleased]: https://github.com/bitcoindevkit/bdk/compare/v0.30.0...HEAD diff --git a/src/wallet/mod.rs b/src/wallet/mod.rs index 485cb9ce2..976562676 100644 --- a/src/wallet/mod.rs +++ b/src/wallet/mod.rs @@ -3526,6 +3526,7 @@ pub(crate) mod test { assert_eq!(details.fee.unwrap_or(0), 200); } + #[allow(deprecated)] #[test] fn test_bump_fee_reduce_single_recipient() { let (wallet, _, _) = get_funded_wallet(get_test_wpkh()); @@ -3572,6 +3573,7 @@ pub(crate) mod test { assert_fee_rate!(psbt, details.fee.unwrap_or(0), FeeRate::from_sat_per_vb(2.5), @add_signature); } + #[allow(deprecated)] #[test] fn test_bump_fee_absolute_reduce_single_recipient() { let (wallet, _, _) = get_funded_wallet(get_test_wpkh()); @@ -3618,6 +3620,7 @@ pub(crate) mod test { assert_eq!(details.fee.unwrap_or(0), 300); } + #[allow(deprecated)] #[test] fn test_bump_fee_drain_wallet() { let (wallet, descriptors, _) = get_funded_wallet(get_test_wpkh()); @@ -4208,6 +4211,7 @@ pub(crate) mod test { builder.finish().unwrap(); } + #[allow(deprecated)] #[test] fn test_bump_fee_unconfirmed_input() { // We create a tx draining the wallet and spending one confirmed diff --git a/src/wallet/tx_builder.rs b/src/wallet/tx_builder.rs index fff704072..990578743 100644 --- a/src/wallet/tx_builder.rs +++ b/src/wallet/tx_builder.rs @@ -653,12 +653,20 @@ impl<'a, D: BatchDatabase> TxBuilder<'a, D, DefaultCoinSelectionAlgorithm, BumpF /// `script_pubkey` in order to bump the transaction fee. Without specifying this the wallet /// will attempt to find a change output to shrink instead. /// + /// **Warning**, use with extreme caution. The specified `script_pubkey` will be used _instead_ + /// of a change address and if the total transaction input amounts are greater than the required + /// outputs + transaction fee the remaining change sats will also be sent to this address. + /// /// **Note** that the output may shrink to below the dust limit and therefore be removed. If it is /// preserved then it is currently not guaranteed to be in the same position as it was /// originally. /// /// Returns an `Err` if `script_pubkey` can't be found among the recipients of the /// transaction we are bumping. + #[deprecated( + since = "0.30.0", + note = "This function will be removed in the next release." + )] pub fn allow_shrinking(&mut self, script_pubkey: ScriptBuf) -> Result<&mut Self, Error> { match self .params