diff options
author | j-berman <justinberman@protonmail.com> | 2022-08-15 19:50:34 -0700 |
---|---|---|
committer | j-berman <justinberman@protonmail.com> | 2022-09-06 17:20:23 -0600 |
commit | b03d7091f7a0c2bd78f28ccb27a6481bb409d4dd (patch) | |
tree | defa75066d02f7b535e826ad88aebb9769bd9195 /src/wallet/wallet2.cpp | |
parent | wallet2: do not assume imported outputs must be non empty (diff) | |
download | monero-b03d7091f7a0c2bd78f28ccb27a6481bb409d4dd.tar.xz |
wallet2: fixes for export/import output flow
- only allow offline wallets to import outputs
- don't import empty outputs
- export subaddress indexes when exporting outputs
Diffstat (limited to 'src/wallet/wallet2.cpp')
-rw-r--r-- | src/wallet/wallet2.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 9caf43cbb..536460396 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -6606,7 +6606,7 @@ bool wallet2::sign_tx(unsigned_tx_set &exported_txs, std::vector<wallet2::pendin { if (!exported_txs.new_transfers.second.empty()) import_outputs(exported_txs.new_transfers); - else if (exported_txs.transfers.second.empty()) + else if (!exported_txs.transfers.second.empty()) import_outputs(exported_txs.transfers); // sign the transactions @@ -13132,6 +13132,8 @@ std::pair<uint64_t, std::vector<tools::wallet2::exported_transfer_details>> wall etd.m_flags.m_key_image_partial = td.m_key_image_partial; etd.m_amount = td.m_amount; etd.m_additional_tx_keys = get_additional_tx_pub_keys_from_extra(td.m_tx); + etd.m_subaddr_index_major = td.m_subaddr_index.major; + etd.m_subaddr_index_minor = td.m_subaddr_index.minor; outs.push_back(etd); } @@ -13162,7 +13164,7 @@ size_t wallet2::import_outputs(const std::pair<uint64_t, std::vector<tools::wall { PERF_TIMER(import_outputs); - THROW_WALLET_EXCEPTION_IF(watch_only(), error::wallet_internal_error, "Hot wallets cannot import outputs"); + THROW_WALLET_EXCEPTION_IF(!m_offline, error::wallet_internal_error, "Hot wallets cannot import outputs"); THROW_WALLET_EXCEPTION_IF(outputs.first > m_transfers.size(), error::wallet_internal_error, "Imported outputs omit more outputs that we know of"); @@ -13230,6 +13232,8 @@ size_t wallet2::import_outputs(const std::pair<uint64_t, std::vector<tools::wall { PERF_TIMER(import_outputs); + THROW_WALLET_EXCEPTION_IF(!m_offline, error::wallet_internal_error, "Hot wallets cannot import outputs"); + THROW_WALLET_EXCEPTION_IF(outputs.first > m_transfers.size(), error::wallet_internal_error, "Imported outputs omit more outputs that we know of. Try using export_outputs all."); |