tui: read the wallet list from the store and load the chosen wallet #144
Loading…
Reference in a new issue
No description provided.
Delete branch "wt/t_895853ad"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Joins the three wallet pieces that already existed but were never wired together: the catalogue in the encrypted store (#141,
wt/t_64c9ba3c), the create/import path that remembers a wallet (#143,wt/t_511023b6), and the selection screen (#142,wt/t_14ac0a3f). Closes the card criterion "selecting a wallet loads it, creating one persists and appears in the list, and the app remembers wallets across restarts".Base/stacking. Base is
wt/t_511023b6because this needs #141's store API and #143'sNode::wallet_create/Node::list_wallets: neither is onmainyet. The branch also carriesd96de1d, a-xcherry-pick of #142's99a4ab6, because the screen has to exist to be wired; when #142 lands onmainthat commit becomes redundant and should drop out of a rebase ontomain. Retarget this PR tomainafter #141, #143 and #142 merge, in that order.What changes
App::open_wallet_select(src/tui.rs) now builds its rows fromNode::list_wallets()at the moment the screen opens, through a newwallet_rowsmapping:name(NULLlabel to empty, rendered as(unlabelled)),identity_pubkeyhex ([u8; 32], not aString),onion_locatorpassthrough (empty is the-placeholder, not an error),created_atas unix seconds. A failed read isWalletSelectState::error(why).F6 wre-reads, so a wallet created or imported in this session is offered the next time the screen opens without a restart.App::choose_walletresolvesWalletChoice::Open(index)against the catalogue as it is now and loads the row at that position. The index is a position, never a store id or an identity key (two records may share one); a list that changed under the screen is reported instead of opening the wrong wallet.+ create new walletstill starts the existing create flow (WalletSetup::CreateWarn).Node::open_wallet(filename)(src/node.rs) is the load step: it refuses a file the catalogue does not hold, re-points the sealed wallet-child record with a read-modify-write (set_wallet_child_config, so the generated RPC creds survive), and restarts a running child onto the new file. An idle child takes the change on its nextstart_wallet_child.App::newstarts onWalletSelectwhen the catalogue is non-empty and on the create flow when it is empty. A catalogue that cannot be read starts on the screen's own error state, where the create row still works.SELECT_UNAVAILABLEand its comment are deleted with the state they described, anddocs/TUI.md's "Saved wallets" section now describes the wired behaviour and the start screen.What deliberately did not change
identity_pubkey/onion_locatorare not pushed into the session. They are catalogue columns recorded at creation: an onion is a locator that rotates (F4) and may be stale or empty, and identity is the roster key the node already holds. The live header keeps reading them from the node, per #141's own contract comment.F9menu row forF6 w. It is a nice-to-have from #142, and the menu's row list is pinned bytests/tui_spec.rs(menu_has_..., theendpoint/child/sync/receive/balance/payments/create/importassertion), which this card's scope does not include.Node::open_walletis additive and UniFFI signatures are untouched, socrates/onionwire-sdkis unaffected.Evidence
cargo test --locked: 35 suites, 0 failures (81 in the lib target).cargo clippy --locked --all-targets -- -D warnings: clean.rustfmt --edition 2024 --check src/tui.rsandsrc/node.rs: same inherited hunk counts as the base (16 and 2), so no new formatting churn.node::tests::open_wallet_points_the_child_at_the_chosen_file_and_keeps_the_creds(chosen file, creds kept, choice survives a reopen) andnode::tests::open_wallet_refuses_a_file_the_catalogue_does_not_hold;tui::wallet_store_tests(5) over a real store-backed, Tor-free node: start screen both ways, catalogue-to-row mapping, row index over a shared identity key, the create row, and a wallet recorded after startup appearing on the next open.open_walletcall sites failedE0599 no method named open_walletbefore the method was added.Test-only additions to
src/node.rsthat a reviewer should know about: the offline node harness (offline_node,NoDial,PASS) is nowpub(crate)and two#[cfg(test)]helpers (test_record_wallet,test_node_with_wallets) were added, becausetests/*.rscannot build aNode(every public constructor bootstraps Tor) and the app-level tests need a real store-backed node. The TUI test helper enters a Tokio runtime before building it — the unbootstrapped Arti client panicsTorClient could not get an asynchronous runtimewithout one.