<p>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.</p>
<p>In this context, a negative value indicates that the feerate is uninitialized or otherwise invalid.</p>

CC BY-SA 4.0
2022-07-10T21:13:04.013Z
2022-07-10T21:13:04.013Z
Ava Chow
<p><a href="https://github.com/bitcoin/bitcoin/blob/master/src/policy/feerate.h#L35" rel="nofollow noreferrer">Here</a> in the definition of <code>CFeeRate</code> class is a member called <code>nSatoshisPerK</code>:</p>
<pre><code>/**
 * Fee rate in satoshis per kilovirtualbyte: CAmount / kvB
 */
class CFeeRate
{
private:
    /** Fee rate in sat/kvB (satoshis per 1000 virtualbytes) */
    CAmount nSatoshisPerK;

</code></pre>
<p>And its job is obvious according to the comment above. This class has also a member called <code>GetFee</code>:</p>
<pre><code>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-&gt;int64_t conversion.
    CAmount nFee{static_cast&lt;CAmount&gt;(std::ceil(nSatoshisPerK * nSize / 1000.0))};

    if (nFee == 0 &amp;&amp; nSize != 0) {
        if (nSatoshisPerK &gt; 0) nFee = CAmount(1);
        if (nSatoshisPerK &lt; 0) nFee = CAmount(-1);
    }

    return nFee;
}
</code></pre>
<p>My question is that in which case it is possible for the <code>nSatoshisPerK</code> to be less than zero? and what does it mean?</p>

<transaction-fees><bitcoin-core-development>
In which situation the fee rate can be negative and what does it really mean?
Amir reza Riahi
# In which situation the fee rate can be negative and what does it really mean?

(Asked by: username_0 on 2022-07-10)

[Here](https://github.com/bitcoin/bitcoin/blob/master/src/policy/feerate.h#L35) in the definition of `CFeeRate` class is a member called `nSatoshisPerK`:

```
/**
 * Fee rate in satoshis per kilovirtualbyte: CAmount / kvB
 */
class CFeeRate
{
private:
    /** 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?

**Tags:** transaction-fees, bitcoin-core-development


---

## 1 answers

### Answer by username_1 on 2022-07-10. Score: 3 | Accepted answer

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.


---

