leaveToWalletRoot method
void
leaveToWalletRoot()
Leave a pushed wallet screen: pop back to the surface that pushed it, or — when this screen IS the navigation root (a host deep-link that mounted it with an empty back stack) — navigate to the wallet root instead.
Money-safety: an exit / "Done" control on a send, swap, or seed-backup
surface must always DO something. A bare pop() on an empty stack is a
silent no-op that strands the user on the money screen with no way home;
the canPop fallback guarantees the affordance is never dead.
Implementation
void leaveToWalletRoot() {
if (canPop()) {
pop();
} else {
go(WalletRoutes.wallet);
}
}