- We select peers to relay to based on their latest known sync height.
- This change:
A) makes sure to update the peer's latest known sync height upon
validating the peer's newly relayed blocks.
B) Allows for a wider window so that if we haven't yet received the
peer's block or finished validating it, then the peer can still be
a valid candidate to receive our new txs.
sweep_main() takes the account to sweep as a parameter, but the index=all
expansion still counts subaddresses on m_current_subaddress_account. sweep_all
and sweep_below pass the current account, so sweep_account is the one command
that ends up with the wrong set.
When the current account has fewer subaddresses than the account being swept,
the set is too small and outputs in the higher minor indices never make it into
the sweep. If none of the target's unlocked outputs land in that range,
create_transactions_all throws "No unlocked balance in the specified
subaddress(es)" for an account that plainly has a balance.
27d551d12f added the account parameter and pointed create_transactions_all at
it, but left this loop on the old field. The RPC path already does it the right
way, with get_num_subaddresses(req.account_index).
export_outputs() says start and count are allowed to go past the valid range,
and that nothing is returned when they do. The loop honours that, but offset
does not: with all=true it takes start unchecked, so a start past the end makes
m_transfers.size() - offset underflow and reserve() gets a value near SIZE_MAX.
vector::reserve throws std::length_error on that, which is where the
"vector::reserve" error in issue #8625 comes from.
Clamping offset also keeps the returned offset usable. import_outputs throws
when offset is past the total, so leaving offset at start would only move the
failure from export to import.
generate_key_image_helper only appended to additional_recv_derivations when
generate_key_derivation succeeded. A tx pubkey that is not a valid point makes
that call fail, so every later derivation shifted down one slot.
is_out_to_acc_precomp indexes that vector by the output index, so once the
list is short the lookup either falls off the bounds check or reads the
derivation belonging to a different output. Either way the helper reports that
the output does not belong to the address, and the wallet cannot build a key
image for an output it owns. Anyone who can put a transaction in front of the
wallet chooses those pubkeys.
The main tx pubkey a few lines up already handles a failed derivation by
keeping its slot and padding with identity, and wallet2 does the same in the
three places it builds this list (wallet2.cpp:2393, :7887, :13397). Do it here
too.