Skip to content

Harden MWC Slatepack runtime and listener lifecycle - #17

Open
sneurlax wants to merge 1 commit into
mainfrom
fix/slatepack-runtime-safety
Open

sneurlax wants to merge 1 commit into
mainfrom
fix/slatepack-runtime-safety

Conversation

@sneurlax

Copy link
Copy Markdown
Member

Summary

Hardens the MWC runtime paths used by Stack Wallet's shared Slatepack UI.

  • preserve structured native errors and the native finalize/broadcast result
  • keep null transaction messages null and avoid duplicate transaction IDs
  • serialize wallet-aware Slatepack encode/decode calls with the native wallet mutex
  • make MWCMQS listener startup, stop, stale-handle replacement, and readiness checks explicit
  • enforce deterministic single-listener ownership: the explicitly active wallet is preferred, background wallets cannot evict it, and exit releases preference
  • estimate fees with the same smallest-output selection used to create the transaction
  • update the example for the asynchronous listener API

Why

The Stack Wallet review found that listener handles could outlive failed starts, multiple MWC wallets could replace each other's singleton listener, a background refresh could steal a recovering active wallet's listener, and the fee estimate could differ from the transaction because the native estimator used a different coin-selection default.

The listener's native is_running signal reports worker health rather than a completed relay authentication. Stack Wallet therefore retries failed workers periodically while keeping ownership deterministic.

Verification

  • native reproducibility matrix: all 11 Apple/iOS, Android, Linux, and Windows artifacts built and recorded as native-8fff521e963f
  • independent Linux rebuild: both ARM64 and x86_64 artifacts match the committed lock exactly
  • cargo test --release --locked: 2 passed
  • flutter test test/protocol_result_test.dart: 11 passed
  • dart analyze lib test example/lib/services: no errors; 3 existing warnings
  • exercised through real MWC UserTesting Slatepack send/receive/finalize, cancellation, broadcast, and confirmation flows in Stack Wallet
  • independently reviewed for pointer lifetime, stop ordering, stale ownership, active-wallet preference, recovery, and exit/refresh serialization; no blocking findings remain

The official MWC UserTesting chain currently requires a test-only compact-header compatibility bypass in the CLI/node harness. No such bypass or regtest dependency is included in this production change.

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