diff options
author | Cédric <cslashm@gmail.com> | 2018-03-05 14:46:15 +0100 |
---|---|---|
committer | cslashm <cslashm@gmail.com> | 2018-03-12 10:43:06 +0100 |
commit | 73dd883d5112e2e8be1a465aca3b3fb48b651afd (patch) | |
tree | 612da8e64d9b036f1934174ab766befa9a0324b7 /src/wallet/wallet2.cpp | |
parent | Merge pull request #3368 (diff) | |
download | monero-73dd883d5112e2e8be1a465aca3b3fb48b651afd.tar.xz |
Ledger HW Bug fixes
Fix the way the REAL mode is handle:
Let create_transactions_2 and create_transactions_from construct the vector of transactions.
Then iterate on it and resign.
We just need to add 'outs' list in the TX struct for that.
Fix default secret keys value when DEBUG_HWDEVICE mode is off
The magic value (00...00 for view key and FF..FF for spend key) was not correctly set
when DEBUG_HWDEVICE was off. Both was set to 00...00.
Add sub-address info in ABP map in order to correctly display destination sub-address on device
Fix DEBUG_HWDEVICE mode:
- Fix compilation errors.
- Fix control device init in ledger device.
- Add more log.
Fix sub addr control
Fix debug Info
Diffstat (limited to '')
-rw-r--r-- | src/wallet/wallet2.cpp | 102 |
1 files changed, 59 insertions, 43 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index d845dd896..9df601181 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -6677,6 +6677,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp cryptonote::transaction tx; pending_tx ptx; size_t bytes; + std::vector<std::vector<tools::wallet2::get_outs_entry>> outs; void add(const account_public_address &addr, bool is_subaddress, uint64_t amount, unsigned int original_output_index, bool merge_destinations) { if (merge_destinations) @@ -7066,40 +7067,10 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_2(std::vector<cryp LOG_PRINT_L2("Made a final " << get_size_string(txBlob) << " tx, with " << print_money(test_ptx.fee) << " fee and " << print_money(test_ptx.change_dts.amount) << " change"); - if ((!dsts.empty()) || - (dsts.empty() && !(adding_fee || !preferred_inputs.empty() || should_pick_a_second_output(use_rct, txes.back().selected_transfers.size(), *unused_transfers_indices, *unused_dust_indices)) ) - ) { - hwdev.set_signature_mode(hw::device::SIGNATURE_REAL); - if (use_rct) { - transfer_selected_rct(tx.dsts, /* NOMOD std::vector<cryptonote::tx_destination_entry> dsts,*/ - tx.selected_transfers, /* const std::list<size_t> selected_transfers */ - fake_outs_count, /* CONST size_t fake_outputs_count, */ - outs, /* MOD std::vector<std::vector<tools::wallet2::get_outs_entry>> &outs, */ - unlock_time, /* CONST uint64_t unlock_time, */ - needed_fee, /* CONST uint64_t fee, */ - extra, /* const std::vector<uint8_t>& extra, */ - test_tx, /* OUT cryptonote::transaction& tx, */ - test_ptx, /* OUT cryptonote::transaction& tx, */ - bulletproof); - } else { - transfer_selected(tx.dsts, - tx.selected_transfers, - fake_outs_count, - outs, - unlock_time, - needed_fee, - extra, - detail::digit_split_strategy, - tx_dust_policy(::config::DEFAULT_DUST_THRESHOLD), - test_tx, - test_ptx); - } - hwdev.set_signature_mode(hw::device::SIGNATURE_FAKE); - } - tx.tx = test_tx; tx.ptx = test_ptx; tx.bytes = txBlob.size(); + tx.outs = outs; accumulated_fee += test_ptx.fee; accumulated_change += test_ptx.change_dts.amount; adding_fee = false; @@ -7139,6 +7110,42 @@ skip_tx: LOG_PRINT_L1("Done creating " << txes.size() << " transactions, " << print_money(accumulated_fee) << " total fee, " << print_money(accumulated_change) << " total change"); + hwdev.set_signature_mode(hw::device::SIGNATURE_REAL); + for (std::vector<TX>::iterator i = txes.begin(); i != txes.end(); ++i) + { + TX &tx = *i; + cryptonote::transaction test_tx; + pending_tx test_ptx; + if (use_rct) { + transfer_selected_rct(tx.dsts, /* NOMOD std::vector<cryptonote::tx_destination_entry> dsts,*/ + tx.selected_transfers, /* const std::list<size_t> selected_transfers */ + fake_outs_count, /* CONST size_t fake_outputs_count, */ + tx.outs, /* MOD std::vector<std::vector<tools::wallet2::get_outs_entry>> &outs, */ + unlock_time, /* CONST uint64_t unlock_time, */ + needed_fee, /* CONST uint64_t fee, */ + extra, /* const std::vector<uint8_t>& extra, */ + test_tx, /* OUT cryptonote::transaction& tx, */ + test_ptx, /* OUT cryptonote::transaction& tx, */ + bulletproof); + } else { + transfer_selected(tx.dsts, + tx.selected_transfers, + fake_outs_count, + tx.outs, + unlock_time, + needed_fee, + extra, + detail::digit_split_strategy, + tx_dust_policy(::config::DEFAULT_DUST_THRESHOLD), + test_tx, + test_ptx); + } + auto txBlob = t_serializable_object_to_blob(test_ptx.tx); + tx.tx = test_tx; + tx.ptx = test_ptx; + tx.bytes = txBlob.size(); + } + std::vector<wallet2::pending_tx> ptx_vector; for (std::vector<TX>::iterator i = txes.begin(); i != txes.end(); ++i) { @@ -7241,6 +7248,7 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_from(const crypton cryptonote::transaction tx; pending_tx ptx; size_t bytes; + std::vector<std::vector<get_outs_entry>> outs; }; std::vector<TX> txes; uint64_t needed_fee, available_for_fee = 0; @@ -7332,24 +7340,13 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_from(const crypton " fee and " << print_money(test_ptx.change_dts.amount) << " change"); } while (needed_fee > test_ptx.fee); - if (!unused_transfers_indices.empty() || !unused_dust_indices.empty()) { - hwdev.set_signature_mode(hw::device::SIGNATURE_REAL); - if (use_rct) { - transfer_selected_rct(tx.dsts, tx.selected_transfers, fake_outs_count, outs, unlock_time, needed_fee, extra, - test_tx, test_ptx, bulletproof); - } else { - transfer_selected(tx.dsts, tx.selected_transfers, fake_outs_count, outs, unlock_time, needed_fee, extra, - detail::digit_split_strategy, tx_dust_policy(::config::DEFAULT_DUST_THRESHOLD), test_tx, test_ptx); - } - hwdev.set_signature_mode(hw::device::SIGNATURE_FAKE); - } - LOG_PRINT_L2("Made a final " << get_size_string(txBlob) << " tx, with " << print_money(test_ptx.fee) << " fee and " << print_money(test_ptx.change_dts.amount) << " change"); tx.tx = test_tx; tx.ptx = test_ptx; tx.bytes = txBlob.size(); + tx.outs = outs; accumulated_fee += test_ptx.fee; accumulated_change += test_ptx.change_dts.amount; if (!unused_transfers_indices.empty() || !unused_dust_indices.empty()) @@ -7362,6 +7359,25 @@ std::vector<wallet2::pending_tx> wallet2::create_transactions_from(const crypton LOG_PRINT_L1("Done creating " << txes.size() << " transactions, " << print_money(accumulated_fee) << " total fee, " << print_money(accumulated_change) << " total change"); + + hwdev.set_signature_mode(hw::device::SIGNATURE_REAL); + for (std::vector<TX>::iterator i = txes.begin(); i != txes.end(); ++i) + { + TX &tx = *i; + cryptonote::transaction test_tx; + pending_tx test_ptx; + if (use_rct) { + transfer_selected_rct(tx.dsts, tx.selected_transfers, fake_outs_count, tx.outs, unlock_time, needed_fee, extra, + test_tx, test_ptx, bulletproof); + } else { + transfer_selected(tx.dsts, tx.selected_transfers, fake_outs_count, tx.outs, unlock_time, needed_fee, extra, + detail::digit_split_strategy, tx_dust_policy(::config::DEFAULT_DUST_THRESHOLD), test_tx, test_ptx); + } + auto txBlob = t_serializable_object_to_blob(test_ptx.tx); + tx.tx = test_tx; + tx.ptx = test_ptx; + tx.bytes = txBlob.size(); + } std::vector<wallet2::pending_tx> ptx_vector; for (std::vector<TX>::iterator i = txes.begin(); i != txes.end(); ++i) |