Fix change detection: handle empty memo correctly
Some checks failed
Rust / Build on macOS-latest (push) Has been cancelled
Rust / Build on ubuntu-16.04 (push) Has been cancelled
Rust / Build on windows-latest (push) Has been cancelled
Rust / Linux ARMv7 (push) Has been cancelled
Rust / Linux ARM64 (push) Has been cancelled
Rust / Build on ubuntu-latest (push) Has been cancelled

memo.to_utf8() returns Some(Ok("")) for change outputs with all-zero
bytes, not None. The previous check (memo.to_utf8().is_none()) never
filtered change outputs because 0x00 < 0xF5 makes to_utf8() treat it
as valid text. Now properly checks for empty string as well.
This commit is contained in:
2026-03-22 10:30:04 -05:00
parent ae059a7238
commit b780587d26

View File

@@ -1482,10 +1482,17 @@ pub fn scan_full_tx(&self, tx: &Transaction, height: i32, datetime: u64) {
try_sapling_note_decryption(ivk, &epk_prime, &output.cmu, &output.enc_ciphertext).is_some()
});
// If this is change (funds to ourself) without a memo, skip it.
// If the user sent a memo to themselves, keep it in outgoing metadata.
if is_to_self && memo.to_utf8().is_none() {
continue;
// If this is change (funds to ourself) without a meaningful memo, skip it.
// memo.to_utf8() returns Some(Ok("")) for empty memos (all-zero bytes),
// so we must also check for empty strings, not just None.
if is_to_self {
let has_memo = match memo.to_utf8() {
Some(Ok(ref s)) if !s.is_empty() => true,
_ => false,
};
if !has_memo {
continue;
}
}
// Update the WalletTx
// Do it in a short scope because of the write lock.