buildWalletConfig function
Build the reference-app WalletConfig for the wallet rooted at dbDir.
The network comes from the ZEC_NETWORK build define (mainnet by default;
testnet for the v-5c device-proof builds) with the matching reference
endpoint (or the ZEC_ENDPOINT override); Tor referenceTorPolicy; the
seed sealed under the device keychain (SeedPersistence.sealedKeychain —
required for revealMnemonic to work after a restart, the Dart-path
default); and a null birthdayHeight (a freshly created wallet starts at
the current tip). The RESTORE path overrides the birthday via
WalletConfigBirthday.withBirthdayHeight (from the user's optional
creation date); the base config stays null for create.
dbDir MUST be a resolved, plain platform path (path_provider), NOT a value
recomputed inside a provider build() — see wallet_composition.dart for
the resolve-before-override discipline (the build()-rerun double-create
footgun).
tor defaults to referenceTorPolicy (off). A host that registered a
transport before opening the wallet — the example's optional Tor plugin —
passes TorPolicy.required_(runtime: TorRuntimeConfig.hostDialer()).
Implementation
WalletConfig buildWalletConfig({
required String dbDir,
List<Uint8List> machineMemoPrefixes = const [],
List<SyncServer>? syncServers,
TorPolicy tor = referenceTorPolicy,
}) {
final network = referenceNetwork();
return WalletConfig(
dbDir: dbDir,
network: network,
endpointUrl: endpointForNetwork(network, override: zecEndpointDefine),
// P3-13: the servers the picker OFFERS. The reference app passes
// `referenceOfferedServers()` (the SDK's public catalog; a host appends
// its own, ADR-0568) from `main()` AFTER the FFI is up; this builder
// stays pure so it is unit-pinned on the host VM. `null` = nothing
// offered beyond the default.
syncServers: syncServers,
tor: tor,
seedPersistence: SeedPersistence.sealedKeychain,
birthdayHeight: null,
broadcastJitter: const JitterPolicy.uniform(
maxMs: referenceBroadcastJitterMaxMs,
),
// FR-27: EMPTY by default — the reference policy defines no machine-memo
// envelope of its own, so `machineMemos` stays closed unless a consumer
// asks for it. The example app passes a demo prefix to exercise the seam;
// a real host passes its own. "Not my feature" is the default, not "off".
machineMemoPrefixes: machineMemoPrefixes,
);
}