Skip to content

Conversation

@reubenyap
Copy link
Member

@reubenyap reubenyap commented Jan 12, 2026

Wallet crashes at times when clicking on Anonymize All or when sending transparent balance to a Spark Address that you own.

PR intention

DeleteMe: Mandatory: What this PR is intended to do, what change it introduces, what issue it solves.

Complete Summary of All Bugs Fixed

Critical Bug (from PR #1734): Uninitialized Transaction in sparkwallet.cpp
Location: src/spark/sparkwallet.cpp, line 1206
Problem: The code was calling mempool.IsTransactionAllowed(*wtx.tx, state) where wtx.tx was still pointing to an empty/uninitialized transaction. The actual signed transaction (txNewConst) was created at line 1186, but wtx.tx is only set at line 1212 (AFTER the mempool check).
Root Cause: When mempool.IsTransactionAllowed() tried to access fields of the empty transaction, it caused EXCEPTION_ACCESS_VIOLATION.
Fix: Changed to use txNewConst (the actual signed transaction) instead of *wtx.tx.

Critical Null Pointer Bugs in wallet.cpp:
Location Issue Fix
Line 7168 CWallet::CreateSparkMintTransactions accessed sparkWallet-> without null check Added null check with error return
Lines 4886, 4902 CreateSparkSpendTransaction and CreateSparkNameTransaction called EnsureMintWalletAvailable() instead of EnsureSparkWalletAvailable() Changed to call the correct function
Line 1839 GetChange() accessed sparkWallet->getMyCoinV() without null check Added null check
Line 1496 AbandonSpends() called on potentially null sparkWallet Added null check
Line 1520 AbandonSparkMints() called on potentially null sparkWallet Added null check
Line 2718 getMyCoinIsChange() called on potentially null sparkWallet Added null check
Previously Fixed Bugs:
File Issue Fix
sparkwallet.cpp (line 1206) PR #1734 bug - using uninitialized wtx.tx instead of txNewConst Changed to use txNewConst
sendcoinsdialog.cpp (line 419) Dangling entry pointer Use static method call
sendcoinsdialog.cpp (lines 691-692) Only updated one entry instead of all Iterate over all entries
sparkmodel.cpp (line 109) Null pointer on sparkWallet Added null check
walletmodeltransaction.cpp (line 71) Null pointer on sparkWallet Added null check
transactionrecord.cpp (lines 187, 190) Null pointer on sparkWallet Added null check

Note

Resolves crashes when sending/minting Spark by hardening wallet/Qt code and fixing a critical mempool check.

  • Use the actual signed transaction (txNewConst) for mempool.IsTransactionAllowed in sparkwallet.cpp to avoid accessing an uninitialized wtx.tx
  • Add null checks for pwalletMain->sparkWallet before accessing Spark data in wallet.cpp, transactionrecord.cpp, walletmodeltransaction.cpp, and sparkmodel.cpp
  • Replace EnsureMintWalletAvailable() with EnsureSparkWalletAvailable() in Spark spend/name creation; add early null check in CreateSparkMintTransactions
  • In sendcoinsdialog.cpp, call SendCoinsEntry::generateWarningText statically and update all SendCoinsEntry widgets when toggling anonymize mode

Written by Cursor Bugbot for commit f31778a. This will update automatically on new commits. Configure here.

…t in various functions to prevent potential crashes. Update transaction handling to ensure proper access to sparkWallet before performing operations. Refactor EnsureMintWalletAvailable to EnsureSparkWalletAvailable for clarity.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 12, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch anonymize-spark-fix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@reubenyap
Copy link
Member Author

bugbot run

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no bugs!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants