Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation for fee_rate and fee_absolute methods in tx_builder.rs #969

Merged
merged 1 commit into from
Sep 19, 2023

Conversation

jonmarrs
Copy link
Contributor

@jonmarrs jonmarrs commented May 4, 2023

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:

Bugfixes:

  • I'm linking the issue being fixed by this PR

Copy link
Contributor Author

@jonmarrs jonmarrs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed extra whitespace.

crates/bdk/src/wallet/tx_builder.rs Outdated Show resolved Hide resolved
@nondiremanuel nondiremanuel added documentation Improvements or additions to documentation BDK 1.0.0 labels May 6, 2023
@jonmarrs jonmarrs changed the title Updating documentation for fee_rate method in tx_builder.rs Update documentation for fee_rate method in tx_builder.rs May 18, 2023
Comment on lines 195 to 196
/// If anyone sets both the fee_absolute method and the fee_rate method,
/// the fee_absolute value will take precedence over the fee_rate.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is correct, the code looks like it will be which ever is set last.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you're right. It looks like FeePolicy in an enum in which only one of either FeeRate or FeeAmount can be set at any time, as they are mutually exclusive.
I've updated the documentation for the fee_absolute() method to clarify this.

@@ -184,12 +184,16 @@ impl<'a, D, Cs: Clone, Ctx> Clone for TxBuilder<'a, D, Cs, Ctx> {
// methods supported by both contexts, for any CoinSelectionAlgorithm
impl<'a, D, Cs: CoinSelectionAlgorithm, Ctx: TxBuilderContext> TxBuilder<'a, D, Cs, Ctx> {
/// Set a custom fee rate
/// The fee_rate method refers to the fee rate in satoshis/vbyte (sats/vbyte).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This takes in a FeeRate which can represent sats/vbyte and sats/kw

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. I see that sats/kwu is a possibility for FeeRate now after looking at the FeeRate type defined in types.rs.
I've updated the documentation for the fee_rate() method to reflect this. Sorry for the confusion, I am a new contributor and am still getting familiar with the code.

@jonmarrs jonmarrs changed the title Update documentation for fee_rate method in tx_builder.rs Update documentation for fee_rate and fee_absolute methods in tx_builder.rs May 19, 2023
@@ -184,12 +184,18 @@ impl<'a, D, Cs: Clone, Ctx> Clone for TxBuilder<'a, D, Cs, Ctx> {
// methods supported by both contexts, for any CoinSelectionAlgorithm
impl<'a, D, Cs: CoinSelectionAlgorithm, Ctx: TxBuilderContext> TxBuilder<'a, D, Cs, Ctx> {
/// Set a custom fee rate
/// The fee_rate method sets the fee rate using a FeeRate type in either satoshis/vbyte (sats/vbyte)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I needed to use this method and came across your PR. I think it is useful to comment a little more how to set fee rates since it is always a source of confusion even for people familiar with Bitcoin, let alone newcomers.
That being said I'd be a little more verbose here, and write something like this:

/// Set the mining fee paid by the transaction as a rate on its size.
    /// This means that the total fee paid is equal to this rate * size of the transaction in virtual Bytes (vB) or Weigth Unit (wu).
    /// This rate is internally expressed in satoshis-per-virtual bytes (sats/vB), but can also be set by:
    /// * sats/kvB (1000 sats/kvB == 1 sats/vB) using FeeRate::from_sat_per_kvb
    /// * btc/kvB (0.00001000 btc/kvB == 1 sats/vB) using FeeRate::from_btc_per_kvb
    /// * sats/kwu (250 sats/kwu == 1 sats/vB) using FeeRate::from_sat_per_kwu
    /// Default is 1 sat/vB (see min_relay_fee)

But maybe that's too verbose now so just a suggestion

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these extra details are a good idea. I've updated the PR to include your suggestion.

@danielabrozzoni
Copy link
Member

Hey, can you please rebase on top of master? Thanks!

@jonmarrs
Copy link
Contributor Author

Hi @danielabrozzoni, I've rebased on top of master. Thank you!

Copy link
Member

@danielabrozzoni danielabrozzoni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please squash your commits together? 6 separate commits for a doc change is a bit too much, one commit is enough. Please don't forget to sign the commit, otherwise I can't merge. Thanks!

@danielabrozzoni
Copy link
Member

Hey, can you please squash and sign your commits?

@jonmarrs jonmarrs force-pushed the patch-2 branch 3 times, most recently from 4f70b88 to 37cda69 Compare September 16, 2023 16:52
@jonmarrs
Copy link
Contributor Author

Alright. I've rebased, squashed, and signed my commits. Sorry for the delay.

@danielabrozzoni
Copy link
Member

No problems for the delay!

Thanks for the squashing/rebasing, it looks good now, but the commit is still not signed. If you need help: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits

@jonmarrs
Copy link
Contributor Author

Sorry about that. The commit should be signed now.

Copy link
Member

@danielabrozzoni danielabrozzoni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK e6519e3

@danielabrozzoni danielabrozzoni merged commit f95506b into bitcoindevkit:master Sep 19, 2023
11 checks passed
@nondiremanuel nondiremanuel added this to the 1.0.0-alpha.2 milestone Sep 23, 2023
@nondiremanuel
Copy link

Assigned to milestone alpha.2 since it was merged in the last days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

6 participants