Skip to content

Fix MWC restore height and empty-wallet fee estimation - #1515

Open
sneurlax wants to merge 3 commits into
stagingfrom
fix/mwc-wallet-correctness
Open

sneurlax wants to merge 3 commits into
stagingfrom
fix/mwc-wallet-correctness

Conversation

@sneurlax

@sneurlax sneurlax commented Nov 13, 2026 •

Copy link
Copy Markdown
Member

Summary

  • use MWC's exact first-block timestamp when estimating restore height
  • skip the native fee call for a non-positive amount or an empty spendable balance
  • keep both calculations in a small pure helper with direct boundary tests
  • prevent libmwc's send-all retry path from reaching a negative amount and aborting the app

Split from #1507 so this correctness fix can be reviewed and merged independently.

Verification

  • helper tests: 2 passed
  • changed helper/test files: no analyzer issues
  • Linux release build: passed
  • earlier combined split integration suite: 136 passed
  • earlier combined Linux release build: passed

Merge ordering

This touches methods that #1507 moves into the shared Mimblewimble base. If #1507 merges first, translate the two helper calls to firstBlockTimestamp and nativeFee; that integration was built and tested locally.

Latest staging refresh (2026-11-17)

Rebased exactly onto staging 1d319093efe5; patch equivalence was confirmed with range-diff. New head: adcb53e9a20e. Focused verification: 3 tests passed. The GitHub Actions Test workflow completed green on the exact refreshed head, including the full Flutter test job, Linux release bundle, and Windows build-script checks.

@sneurlax
sneurlax marked this pull request as draft November 13, 2026 22:50
@codecov

codecov Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 16.33%. Comparing base (a31b28b) to head (adcb53e).
⚠️ Report is 4 commits behind head on staging.

Files with missing lines Patch % Lines
...b/wallets/wallet/impl/mimblewimblecoin_wallet.dart 0.00% 3 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           staging    #1515      +/-   ##
===========================================
+ Coverage    16.11%   16.33%   +0.22%     
===========================================
  Files         1145     1146       +1     
  Lines       114390   114416      +26     
===========================================
+ Hits         18429    18686     +257     
+ Misses       95961    95730     -231     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@sneurlax
sneurlax marked this pull request as ready for review November 14, 2026 03:48
The MWC wallet copied Epic Cash's first-block timestamp (1565370278)
under the name mimblewimblecoinFirstBlock. MWC mainnet started on
2019-11-11 (1573462801, the value restore_wallet_view already uses), so
the estimate for a freshly created wallet landed about 130k blocks above
the actual tip: the initial scan and any later rescan from that height
never ran. Wallets restored from a seed were unaffected.

Staging already fixed this in 0e56467 with 1573462800. Rebased onto
it, this only aligns the value with restore_wallet_view.
Opening Send on an empty MWC wallet asks for a fee estimate. libmwc treats
amount == available as send all, retries with the amount minus the
required fee and aborts the app on the resulting negative amount (seen on
the iOS Simulator as a SIGABRT in mwc_rust_get_tx_fees). There is no fee to
estimate without a spendable balance or an amount, so return 0 without
calling the native library. The real send still reports insufficient
funds.
@sneurlax
sneurlax force-pushed the fix/mwc-wallet-correctness branch from 5014cb9 to adcb53e Compare November 17, 2026 19:53
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.

1 participant