<p>CAmount is used for multiple purposes in Bitcoin Core, not just in transaction validation logic. It is also used to represent the net effect transactions have on wallet balance, for example, and that net effect is negative as often as it is positive.</p>

CC BY-SA 4.0
2021-11-29T13:39:48.840Z
2021-11-29T13:39:48.840Z
Pieter Wuille
<p>Is there is reason why Bitcoin uses signed instead of unsigned integers for amounts? I can't imagine a scenario where negative amounts could come up. Was it simply something Satoshi implemented for some future use this way and now we are stuck with it?</p>

CC BY-SA 4.0
2021-11-29T21:03:18.087Z
As an aside, in C++ it is considered bad practice to use unsigned variable just because the underlying thing they represent can only be a positive value.  There are a lot of traps in the language when you mixed signed and unsigned quantities thanks to the way implicit conversions work.  This might have had some influence as well, since the original implementation was in C++.
Chuu
<bitcoin-core-development><consensus><c++>
Why is CAmount a signed integer?
Arnor
# Why is CAmount a signed integer?

(Asked by: username_0 on 2021-11-29)

Is there is reason why Bitcoin uses signed instead of unsigned integers for amounts? I can't imagine a scenario where negative amounts could come up. Was it simply something Satoshi implemented for some future use this way and now we are stuck with it?

**Tags:** bitcoin-core-development, consensus, c++

> **Comments:**
> **username_1**: As an aside, in C++ it is considered bad practice to use unsigned variable just because the underlying thing they represent can only be a positive value.  There are a lot of traps in the language when you mixed signed and unsigned quantities thanks to the way implicit conversions work.  This might have had some influence as well, since the original implementation was in C++.  

---

## 1 answers

### Answer by username_2 on 2021-11-29. Score: 5 | Accepted answer

CAmount is used for multiple purposes in Bitcoin Core, not just in transaction validation logic. It is also used to represent the net effect transactions have on wallet balance, for example, and that net effect is negative as often as it is positive.


---

