oxen-core/src
Jason Rhinelander 4f721c0098 Make tx type and version scoped enums
This converts the transaction type and version to scoped enum, giving
type safety and making the tx type assignment less error prone because
there is no implicit conversion or comparison with raw integers that has
to be worried about.

This ends up converting any use of `cryptonote::transaction::type_xyz`
to `cryptonote::transaction::txtype::xyz`.  For version, names like
`transaction::version_v4` become `cryptonote::txversion::v4_tx_types`.

This also allows/includes various other simplifications related to or
enabled by this change:
- handle `is_deregister` dynamically in serialization code (setting
  `type::standard` or `type::deregister` rather than using a
  version-determined union)
- `get_type()` is no longer needed with the above change: it is now
  much simpler to directly access `type` which will always have the
  correct value (even for v2 or v3 transaction types).  And though there
  was an assertion on the enum value, `get_type()` was being used only
  sporadically: many places accessed `.type` directly.
- the old unscoped enum didn't have a type but was assumed castable
  to/from `uint16_t`, which technically meant there was potential
  undefined behaviour when deserializing any type values >= 8.
- tx type range checks weren't being done in all serialization paths;
  they are now.  Because `get_type()` was not used everywhere (lots of
  places simply accessed `.type` directory) these might not have been
  caught.
- `set_type()` is not needed; it was only being used in a single place
  (wallet2.cpp) and only for v4 txes, so the version protection code was
  never doing anything.
- added a std::ostream << operator for the enum types so that they can be
  output with `<< tx_type <<` rather than needing to wrap it in
  `type_to_string(tx_type)` everywhere.  For the versions, you get the
  annotated version string (e.g. 4_tx_types) rather than just the number
  4.
2019-06-19 17:47:03 -03:00
..
blockchain_db Make tx type and version scoped enums 2019-06-19 17:47:03 -03:00
blockchain_utilities Make tx type and version scoped enums 2019-06-19 17:47:03 -03:00
blocks Update monero copyright to 2019 pre-emptively to make merge simpler 2019-04-12 14:36:43 +10:00
checkpoints Service Node Checkpointing: More reliable transportation of votes, culling of old checkpoints (#632) 2019-06-13 18:01:08 +10:00
common Merge commit '5e80b3c' into LokiMergeUpstream 2019-05-17 04:14:11 +10:00
crypto Merge commit '98f4c8a' into LokiMergeUpstream 2019-05-01 17:04:00 +10:00
cryptonote_basic Make tx type and version scoped enums 2019-06-19 17:47:03 -03:00
cryptonote_core Make tx type and version scoped enums 2019-06-19 17:47:03 -03:00
cryptonote_protocol Drop connection when requesting duplicated tx indexes (#637) 2019-06-12 17:48:46 +10:00
daemon Various integration test fixes (#628) 2019-06-06 14:44:57 +10:00
daemonizer Merge commit '581994b' into LokiMergeUpstream 2019-05-02 14:15:02 +10:00
debug_utilities Merge commit 'f2f725d8db3535055d1c7e102c0bba75b22a3409' into LokiMergeUpstream 2019-04-12 15:23:01 +10:00
device Fix ledger re-declaration of is_change 2019-05-07 15:52:17 +10:00
device_trezor Make tx type and version scoped enums 2019-06-19 17:47:03 -03:00
gen_multisig Update monero copyright to 2019 pre-emptively to make merge simpler 2019-04-12 14:36:43 +10:00
lmdb Merge commit '5e80b3c' into LokiMergeUpstream 2019-05-17 04:14:11 +10:00
mnemonics mnemonics: fix 4 byte UTF-8 rewriting 2019-04-30 21:10:54 +00:00
multisig Update monero copyright to 2019 pre-emptively to make merge simpler 2019-04-12 14:36:43 +10:00
net Merge commit '7acfa9f3cc7b52c0f4776dde3c3f80674cc3306f' into LokiMergeUpstream 2019-04-12 16:56:45 +10:00
p2p Merge commit 'ebb1c03' into LokiMergeUpstream 2019-05-17 03:43:06 +10:00
platform Update monero copyright to 2019 pre-emptively to make merge simpler 2019-04-12 14:36:43 +10:00
ringct Merge commit 'e98cbfb' into LokiMergeUpstream 2019-05-02 12:28:01 +10:00
rpc RPC endpoint for requesting random snodes (#638) 2019-06-13 18:00:38 +10:00
serialization Make tx type and version scoped enums 2019-06-19 17:47:03 -03:00
simplewallet Don't access array OOB when parsing percentage in stakes (#636) 2019-06-11 12:07:50 +10:00
wallet Make tx type and version scoped enums 2019-06-19 17:47:03 -03:00
CMakeLists.txt Merge commit '6f07b8ffa555fb3b64c4d5007acd46f496c28d19' into LokiMergeUpstream 2019-04-12 15:33:38 +10:00
cryptonote_config.h Require storage server running for uptime proofs (v.2) (#631) 2019-06-07 17:03:11 +10:00
version.cpp.in Bump patch version to 6 (#600) 2019-05-12 10:06:07 +10:00
version.h Add versioning to uptime proofs to enforce behaviour 2018-11-05 15:52:44 +11:00