Skip to content

Commit f95506b

Browse files
Merge #969: Update documentation for fee_rate and fee_absolute methods in tx_builder.rs
e6519e3 Enhance the documentation for the fee_rate and fee_absolute methods. (Jon Marrs) Pull request description: ### Description This pr helps solve this issue: #856 I added documentation to the fee_rate() method to describe the units as either satoshis/vbyte (sats/vbyte) or satoshis/kwu (sats/kwu), depending on the FeeRate type. I also added documentation to the fee_absolute() method to clarify that the fee is determined by whichever method (fee_rate or fee_absolute) was called last, as the FeePolicy is an enum, and FeeRate/FeeAmount are mutually exclusive. ### Notes to the reviewers I thought it would be helpful to provide documentation to alleviate confusion over the fee_rate method and the fee_absolute method. ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) #### Bugfixes: * [x] I'm linking the issue being fixed by this PR ACKs for top commit: danielabrozzoni: ACK e6519e3 Tree-SHA512: 59f62d1d1f8355e6353c6a2550e464732975c86c767648adc9143f2b3a9b894a90536a30a33e9de7efbe53f16392ec2e19008d884fb65ef037edae64a3cb6970
2 parents 43fb0b2 + e6519e3 commit f95506b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

crates/bdk/src/wallet/tx_builder.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,13 @@ impl<'a, D, Cs: Clone, Ctx> Clone for TxBuilder<'a, D, Cs, Ctx> {
181181
// methods supported by both contexts, for any CoinSelectionAlgorithm
182182
impl<'a, D, Cs: CoinSelectionAlgorithm, Ctx: TxBuilderContext> TxBuilder<'a, D, Cs, Ctx> {
183183
/// Set a custom fee rate
184+
/// The fee_rate method sets the mining fee paid by the transaction as a rate on its size.
185+
/// This means that the total fee paid is equal to this rate * size of the transaction in virtual Bytes (vB) or Weigth Unit (wu).
186+
/// This rate is internally expressed in satoshis-per-virtual-bytes (sats/vB) using FeeRate::from_sat_per_vb, but can also be set by:
187+
/// * sats/kvB (1000 sats/kvB == 1 sats/vB) using FeeRate::from_sat_per_kvb
188+
/// * btc/kvB (0.00001000 btc/kvB == 1 sats/vB) using FeeRate::from_btc_per_kvb
189+
/// * sats/kwu (250 sats/kwu == 1 sats/vB) using FeeRate::from_sat_per_kwu
190+
/// Default is 1 sat/vB (see min_relay_fee)
184191
pub fn fee_rate(&mut self, fee_rate: FeeRate) -> &mut Self {
185192
self.params.fee_policy = Some(FeePolicy::FeeRate(fee_rate));
186193
self
@@ -189,7 +196,8 @@ impl<'a, D, Cs: CoinSelectionAlgorithm, Ctx: TxBuilderContext> TxBuilder<'a, D,
189196
/// Set an absolute fee
190197
/// The fee_absolute method refers to the absolute transaction fee in satoshis (sats).
191198
/// If anyone sets both the fee_absolute method and the fee_rate method,
192-
/// the fee_absolute value will take precedence over the fee_rate.
199+
/// the FeePolicy enum will be set by whichever method was called last,
200+
/// as the FeeRate and FeeAmount are mutually exclusive.
193201
pub fn fee_absolute(&mut self, fee_amount: u64) -> &mut Self {
194202
self.params.fee_policy = Some(FeePolicy::FeeAmount(fee_amount));
195203
self

0 commit comments

Comments
 (0)