oxen-core/src/device_trezor
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
..
trezor Make tx type and version scoped enums 2019-06-19 17:47:03 -03:00
CMakeLists.txt Merge commit 'c88e9921043d7c40f023d24c3a3f39f2e96f8738' into LokiMergeUpstream 2019-04-12 14:17:05 +10:00
device_trezor.cpp Merge commit 'bd42903' into LokiMergeUpstream 2019-04-12 18:37:56 +10:00
device_trezor.hpp Update monero copyright to 2019 pre-emptively to make merge simpler 2019-04-12 14:36:43 +10:00
device_trezor_base.cpp Merge branch 'monero' into LokiMergeUpstream 2019-05-06 14:04:29 +10:00
device_trezor_base.hpp Update monero copyright to 2019 pre-emptively to make merge simpler 2019-04-12 14:36:43 +10:00
trezor.hpp Update monero copyright to 2019 pre-emptively to make merge simpler 2019-04-12 14:36:43 +10:00