exportPrivateKey method

Future<void> exportPrivateKey()

Reveals this wallet's private key to the user via whatever ExportPrivateKeyCapability is installed on the client it was built from (useExportPrivateKey(...) — see that capability's docstring for the exact UX contract: a visible, screenshot-protected reveal the user must explicitly dismiss, never surfaced to this SDK or its host app). PRECONDITION: same single-implementation caveat as signMessage — see that method's doc; today there is exactly one ExportPrivateKeyCapability implementation (ExportPrivateKeyExtension), so this is safe.

Implementation

Future<void> exportPrivateKey() async {
  final client = this.client;
  if (client == null) {
    throw DynamicStateException("this model's owning client is no longer available");
  }
  final exporter = client.findCapability<ExportPrivateKeyCapability>();
  if (exporter == null) {
    throw DynamicStateException("no export-private-key capability installed on this wallet's client (e.g. useExportPrivateKey) — add one first");
  }
  await exporter.exportPrivateKey(this.chain, this.address);
}