Skip to content

Simplify DrainWeights/Target API #1

Closed
@evanlinjin

Description

@evanlinjin

Original discussion: bitcoindevkit/bdk#1072 (comment)

@jp1ac4 @darosior I'm working on some breaking changes to the API.

After a discussion with @LLFourn, we've decided to include DrainWeights in Target and keep Target in the CoinSelector. This simplifies the API and gives us an easy pathway to take into account the output count varint weight changes when including the drain output.

How this simplifies the API:

  • The target & drain weights are included in the CoinSelector, so they don't need to be passed in as method inputs.
  • Change policy can be simplified to just: Fn(&CoinSelector) -> bool.

How we can take into account the output varint weight changes when including drain:

pub struct Target {
    /*other fields*/

    pub base_weight: u32,
    pub drain_weights: DrainWeights,
}

impl Target {
    pub fn new(
        feerate: FeeRate,
        recipient_outputs: impl IntoIterator<Item = (u32 /*weight*/, u64 /*value*/)>
        drain_outputs: impl IntoIterator<Item = DrainWeights>,
    ) -> Self {
        todo!()
    }
}

This calculates the base_weight and the drain_weight (which includes output varint changes) that are both included in Target.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions