Skip to content

Commit

Permalink
Merge bitcoin#18030: doc: Coin::IsSpent() can also mean never existed
Browse files Browse the repository at this point in the history
1404c57 [doc] Coin: explain that IsSpent() can also mean never existed (Sjors Provoost)

Pull request description:

  This can be especially confusing where `AccessCoin()` is used with logic like this:

  ```c++
      while (iter.n < MAX_OUTPUTS_PER_BLOCK) {
          const Coin& alternate = view.AccessCoin(iter);
          if (!alternate.IsSpent()) return alternate;
  ```

ACKs for top commit:
  practicalswift:
    ACK 1404c57
  MarcoFalke:
    ACK 1404c57
  jnewbery:
    utACK 1404c57

Tree-SHA512: 418618dd7e08bd5cc8360e3501d0f57e34100e5101ad3b8e0a819923fa860f44c7f2fada0f8447a1af3c2601fd72bfe619b91ff2f26f7133ceaeb0c98b017b12
  • Loading branch information
MarcoFalke authored and PastaPastaPasta committed Jul 16, 2021
1 parent 9ff78a0 commit cfd9a89
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/coins.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ class Coin
::Unserialize(s, Using<TxOutCompression>(out));
}

/** Either this coin never existed (see e.g. coinEmpty in coins.cpp), or it
* did exist and has been spent.
*/
bool IsSpent() const {
return out.IsNull();
}
Expand Down

0 comments on commit cfd9a89

Please sign in to comment.