diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-06-16 23:58:54 +0100 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2016-08-28 21:28:47 +0100 |
commit | 089df4af831520e0a16b643b876da37222bf4663 (patch) | |
tree | daad561b703bd2811a75608fdf6ce97bdda0803c /src/wallet/wallet2.h | |
parent | ringct: catch errors from ge_frombytes_vartime (diff) | |
download | monero-089df4af831520e0a16b643b876da37222bf4663.tar.xz |
wallet: reset output spent status on blockchain reorg
If the blockchain gets reorganized, all outputs spent in the part
of the blockchain that's blown away need to be reset to unspent
(they may end up spent again on the blocks that replace the blocks
that are removed, however).
Diffstat (limited to 'src/wallet/wallet2.h')
-rw-r--r-- | src/wallet/wallet2.h | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h index 125f8edb5..1c835429f 100644 --- a/src/wallet/wallet2.h +++ b/src/wallet/wallet2.h @@ -103,6 +103,7 @@ namespace tools size_t m_internal_output_index; uint64_t m_global_output_index; bool m_spent; + uint64_t m_spent_height; crypto::key_image m_key_image; //TODO: key_image stored twice :( rct::key m_mask; uint64_t m_amount; @@ -490,7 +491,7 @@ namespace tools }; } BOOST_CLASS_VERSION(tools::wallet2, 13) -BOOST_CLASS_VERSION(tools::wallet2::transfer_details, 1) +BOOST_CLASS_VERSION(tools::wallet2::transfer_details, 2) BOOST_CLASS_VERSION(tools::wallet2::payment_details, 1) BOOST_CLASS_VERSION(tools::wallet2::unconfirmed_transfer_details, 4) BOOST_CLASS_VERSION(tools::wallet2::confirmed_transfer_details, 2) @@ -500,14 +501,21 @@ namespace boost namespace serialization { template <class Archive> - inline void initialize_transfer_details(Archive &a, tools::wallet2::transfer_details &x) + inline void initialize_transfer_details(Archive &a, tools::wallet2::transfer_details &x, const boost::serialization::version_type ver) { } template<> - inline void initialize_transfer_details(boost::archive::binary_iarchive &a, tools::wallet2::transfer_details &x) + inline void initialize_transfer_details(boost::archive::binary_iarchive &a, tools::wallet2::transfer_details &x, const boost::serialization::version_type ver) { - x.m_mask = rct::identity(); - x.m_amount = x.m_tx.vout[x.m_internal_output_index].amount; + if (ver < 1) + { + x.m_mask = rct::identity(); + x.m_amount = x.m_tx.vout[x.m_internal_output_index].amount; + } + if (ver < 2) + { + x.m_spent_height = 0; + } } template <class Archive> @@ -522,11 +530,17 @@ namespace boost if (ver < 1) { // ensure mask and amount are set - initialize_transfer_details(a, x); + initialize_transfer_details(a, x, ver); return; } a & x.m_mask; a & x.m_amount; + if (ver < 2) + { + initialize_transfer_details(a, x, ver); + return; + } + a & x.m_spent_height; } template <class Archive> |