Here in the definition of CFeeRate class is a member called nSatoshisPerK:

 * Fee rate in satoshis per kilovirtualbyte: CAmount / kvB
class CFeeRate
    /** Fee rate in sat/kvB (satoshis per 1000 virtualbytes) */
    CAmount nSatoshisPerK;

And its job is obvious according to the comment above. This class has also a member called GetFee:

CAmount CFeeRate::GetFee(uint32_t num_bytes) const
    const int64_t nSize{num_bytes};

    // Be explicit that we're converting from a double to int64_t (CAmount) here.
    // We've previously had issues with the silent double->int64_t conversion.
    CAmount nFee{static_cast<CAmount>(std::ceil(nSatoshisPerK * nSize / 1000.0))};

    if (nFee == 0 && nSize != 0) {
        if (nSatoshisPerK > 0) nFee = CAmount(1);
        if (nSatoshisPerK < 0) nFee = CAmount(-1);

    return nFee;

My question is that in which case it is possible for the nSatoshisPerK to be less than zero? and what does it mean?

1 Answer 1


It is not possible for the feerate to be less than 0. It would mean that the outputs have more value than the inputs, which means that Bitcoin is being created from thin air. Such a transaction would be invalid and it is not possible to have negative feerates.

In this context, a negative value indicates that the feerate is uninitialized or otherwise invalid.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.