Skip to content

Bug: Using Candidate::new_tr_keyspend adds TXIN_BASE_WEIGHT twice to the weight #31

@cygnet3

Description

@cygnet3

In coin_selector.rs, the body of Candidate::new_tr_keyspend looks like this:

pub fn new_tr_keyspend(value: u64) -> Self {
    let weight = TXIN_BASE_WEIGHT + TR_KEYSPEND_SATISFACTION_WEIGHT;
    Self::new(value, weight, true)
}

next, Self::new has this:

pub fn new(value: u64, satisfaction_weight: u64, is_segwit: bool) -> Candidate {
    let weight = TXIN_BASE_WEIGHT + satisfaction_weight;
    Candidate {
        value,
        weight,
        input_count: 1,
        is_segwit,
    }
}

So TXIN_BASE_WEIGHT is counted twice.

To fix, the duplicate TXIN_BASE_WEIGHT should be removed from the body of Candidate::new_tr_keyspend.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions