Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions assets/languages/strings_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"buyPaymentConfirmFailedAktionariat": "Es gibt ein technisches Problem. Bitte überprüfen Sie Ihr E-Mail-Postfach, möglicherweise fehlt noch eine Bestätigung Ihrer Blockchain-Adresse. Andernfalls versuchen Sie es später erneut. Falls der Fehler weiterhin besteht, kontaktieren Sie unseren Support.",
"buyPaymentInformation": "Zahlungsinformationen",
"buyPaymentInformationDescription": "Bitte überweisen Sie den Kaufbetrag mit diesen Angaben über Ihre Bankanwendung. Der Verwendungszweck ist wichtig!",
"buyRealUnit": "RealUnit kaufen",
"buyRealu": "RealUnit Token kaufen",
"buyRealUnit": "RealUnit kaufen",
"cancel": "Abbrechen",
"changeAddress": "Adresse ändern",
"changeInReview": "Änderung in Prüfung",
Expand All @@ -53,11 +53,13 @@
"connectBitboxContent": "Bitte verbinden Sie Ihre BitBox mit Ihrem Smartphone.",
"connectBitboxContentIos": "Bitte verbinden Sie Ihre BitBox mit Ihrem Smartphone und aktivieren Sie zusätzlich Bluetooth.",
"connectBitboxFailed": "Es ist ein Fehler aufgetreten. Bitte versuchen Sie es erneut.",
"connectBitboxSignInHint": "Nach der Code-Überprüfung wird die BitBox um eine zusätzliche Bestätigung zur Anmeldung gebeten.",
"connectBitboxNotInitialized": "Auf dieser BitBox ist noch keine Wallet eingerichtet. Bitte richten Sie über die BitBox-App eine Wallet auf dem Gerät ein oder stellen Sie eine wieder her und versuchen Sie es erneut.",
"connectBitboxNotInitializedTitle": "BitBox noch nicht eingerichtet",
"connectBitboxSignatureCapturing": "Bitte bestätigen Sie die Anmeldeanfrage auf Ihrem BitBox-Gerät. Diese Signatur wird einmalig erfasst, damit künftige Käufe Ihre BitBox nicht erneut benötigen.",
"connectBitboxSignatureCapturingTitle": "Anmeldung bestätigen",
"connectBitboxSignatureFailed": "Ihre Anmeldesignatur konnte nicht erfasst werden. Sie können es erneut versuchen oder trotzdem fortfahren – Ihre BitBox wird dann möglicherweise für Ihren ersten Kauf erneut benötigt.",
"connectBitboxSignatureFailedTitle": "Anmeldung nicht abgeschlossen",
"connectBitboxSignInHint": "Nach der Code-Überprüfung wird die BitBox um eine zusätzliche Bestätigung zur Anmeldung gebeten.",
"connectBitboxTitle": "BitBox verbinden",
"connected": "Verbunden",
"connectedBitboxContent": "Bitte bestätigen Sie und folgen nun den letzten Anweisungen auf Ihrer BitBox.",
Expand Down Expand Up @@ -198,8 +200,8 @@
"proofDocument": "Nachweis-Dokument",
"purposeOfPayment": "Verwendungszweck",
"qrCode": "QR-Code",
"realunitStockToken": "RealUnit Aktientoken",
"realunitStockprice": "RealUnit Aktienkurs",
"realunitStockToken": "RealUnit Aktientoken",
"realunitWallet": "RealUnit Wallet",
"realunitWalletLogout": "Aus REALU Wallet abmelden",
"realunitWalletLogoutCheck": "Ich habe meine Wiederherstellungsphrase gesichert.",
Expand Down Expand Up @@ -246,18 +248,18 @@
"sellBitboxCheckingEth": "Wallet-Guthaben wird geprüft",
"sellBitboxDepositDescription": "Bestätigen Sie auf der BitBox, um ZCHF an die DFX-Einzahlungsadresse zu überweisen.",
"sellBitboxDepositFrom": "Sie senden",
"sellBitboxDepositing": "ZCHF wird gesendet. Bestätigen Sie auf der Bitbox",
"sellBitboxDepositRetryDescription": "Der Tausch wurde abgeschlossen, aber die ZCHF-Einzahlung konnte nicht gesendet werden. Ihre Mittel sind sicher. Tippen Sie auf Wiederholen.",
"sellBitboxDepositRetryTitle": "Einzahlung fehlgeschlagen",
"sellBitboxDepositTitle": "ZCHF an DFX senden",
"sellBitboxDepositTo": "DFX-Einzahlung",
"sellBitboxDepositing": "ZCHF wird gesendet. Bestätigen Sie auf der Bitbox",
"sellBitboxEthReady": "Wallet bereit",
"sellBitboxEthReadyDescription": "Ihr Wallet hat genug ETH, um mit dem Verkauf fortzufahren.",
"sellBitboxSwapDescription": "Bestätigen Sie auf Ihrem BitBox, um REALU über den BrokerBot in ZCHF zu tauschen.",
"sellBitboxSwapFrom": "Sie senden",
"sellBitboxSwapping": "Tausch on-chain. Bestätigen Sie auf der Bitbox.",
"sellBitboxSwapTitle": "REALU → ZCHF tauschen",
"sellBitboxSwapTo": "Sie erhalten",
"sellBitboxSwapping": "Tausch on-chain. Bestätigen Sie auf der Bitbox.",
"sellBitboxWaitingForEth": "Gasgebühren werden angefordert",
"sellBitboxWaitingForEthDescription": "Ein kleiner ETH-Betrag wird an Ihr Wallet gesendet, um die Transaktionsgebühren zu decken. Dies kann einige Minuten dauern.",
"sellMinAmount": "Mindestbetrag: ${amount} ${currency}",
Expand All @@ -282,10 +284,10 @@
"settingsWalletBackupSubtitle1": "Bitte notieren Sie Ihre 12 Wiederherstellungs-Wörter in der exakten Reihenfolge auf einem Blatt Papier und bewahren Sie sie absolut sicher auf.",
"settingsWalletBackupSubtitle2": "Dies ist die einzige Möglichkeit, Ihre Wallet wiederherzustellen.",
"showSeed": "Seed anzeigen",
"signMessage": "Signierte Nachricht",
"signMessageGet": "Signierte Nachricht abrufen",
"signature": "Signatur",
"signingCancelled": "Signatur abgebrochen — bitte BitBox erneut bestätigen",
"signMessage": "Signierte Nachricht",
"signMessageGet": "Signierte Nachricht abrufen",
"skip": "Überspringen",
"softwareTermsText": "Mit der Nutzung dieser App akzeptieren Sie die Nutzungsbedingungen dieser Software.",
"softwareTermsTextHighlighted": "Nutzungsbedingungen",
Expand Down Expand Up @@ -329,9 +331,9 @@
"transactionBuy": "Kauf",
"transactionHistory": "Transaktionshistorie",
"transactionPending": "In Bearbeitung",
"transactions": "Transaktionen",
"transactionSell": "Verkauf",
"transactionWaitingForPayment": "Warte auf Zahlung",
"transactions": "Transaktionen",
"twoFa": "2-Faktor Authentifizierung",
"twoFaCodeRequired": "Code ist erforderlich",
"twoFaCodeTooShort": "Der Code sollte 6 Ziffern lang sein",
Expand All @@ -356,4 +358,4 @@
"youPay": "Sie bezahlen",
"youReceive": "Sie erhalten",
"youSell": "Sie verkaufen"
}
}
20 changes: 11 additions & 9 deletions assets/languages/strings_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
"buyPaymentConfirmFailedAktionariat": "There is a technical problem. Please check your email inbox — you may still need to confirm your blockchain address. Otherwise, please try again later. If the error persists, contact our support team.",
"buyPaymentInformation": "Payment information",
"buyPaymentInformationDescription": "Please transfer the purchase amount using your banking app with these details. The purpose of payment is important!",
"buyRealUnit": "Buy RealUnit",
"buyRealu": "Buy RealUnit Token",
"buyRealUnit": "Buy RealUnit",
"cancel": "Cancel",
"changeAddress": "Change address",
"changeInReview": "Change in review",
Expand All @@ -53,11 +53,13 @@
"connectBitboxContent": "Please connect your BitBox with your Smartphone.",
"connectBitboxContentIos": "Please connect your BitBox with your Smartphone and activate Bluetooth.",
"connectBitboxFailed": "Something went wrong. Please try to connect again.",
"connectBitboxSignInHint": "After verifying the code, the BitBox will ask for one additional confirmation to sign you in.",
"connectBitboxNotInitialized": "This BitBox has no wallet set up yet. Set up or restore a wallet on the device using the BitBox app, then try again.",
"connectBitboxNotInitializedTitle": "BitBox not set up yet",
"connectBitboxSignatureCapturing": "Please confirm the sign-in request on your BitBox device. This signature is captured once so future purchases won't need your BitBox again.",
"connectBitboxSignatureCapturingTitle": "Confirm sign-in",
"connectBitboxSignatureFailed": "We couldn't capture your sign-in signature. You can retry, or continue anyway – your BitBox may then be needed again for your first purchase.",
"connectBitboxSignatureFailedTitle": "Sign-in not completed",
"connectBitboxSignInHint": "After verifying the code, the BitBox will ask for one additional confirmation to sign you in.",
"connectBitboxTitle": "Connect BitBox",
"connected": "Connected",
"connectedBitboxContent": "Please confirm and follow the last steps on your BitBox.",
Expand Down Expand Up @@ -198,8 +200,8 @@
"proofDocument": "Proof document",
"purposeOfPayment": "Purpose of payment",
"qrCode": "QR code",
"realunitStockToken": "RealUnit Stock Token",
"realunitStockprice": "RealUnit Stockprice",
"realunitStockToken": "RealUnit Stock Token",
"realunitWallet": "RealUnit Wallet",
"realunitWalletLogout": "Log out of REALU Wallet",
"realunitWalletLogoutCheck": "I have backed up my recovery phrase.",
Expand Down Expand Up @@ -246,18 +248,18 @@
"sellBitboxCheckingEth": "Checking your wallet balance",
"sellBitboxDepositDescription": "Confirm on your BitBox to transfer ZCHF to the DFX deposit address.",
"sellBitboxDepositFrom": "You send",
"sellBitboxDepositing": "Sending ZCHF. Please confirm on the Bitbox.",
"sellBitboxDepositRetryDescription": "The swap was completed but the ZCHF deposit could not be sent. Your funds are safe. Tap retry to try again.",
"sellBitboxDepositRetryTitle": "Deposit failed",
"sellBitboxDepositTitle": "Send ZCHF to DFX",
"sellBitboxDepositTo": "DFX deposit",
"sellBitboxDepositing": "Sending ZCHF. Please confirm on the Bitbox.",
"sellBitboxEthReady": "Wallet ready",
"sellBitboxEthReadyDescription": "Your wallet has enough ETH to proceed with the sale.",
"sellBitboxSwapDescription": "Confirm on your BitBox to swap REALU for ZCHF via the BrokerBot.",
"sellBitboxSwapFrom": "You send",
"sellBitboxSwapping": "Swapping on-chain. Please confirm on the Bitbox.",
"sellBitboxSwapTitle": "Swap REALU → ZCHF",
"sellBitboxSwapTo": "You receive",
"sellBitboxSwapping": "Swapping on-chain. Please confirm on the Bitbox.",
"sellBitboxWaitingForEth": "Requesting gas funds",
"sellBitboxWaitingForEthDescription": "A small amount of ETH is being sent to your wallet to cover transaction fees. This may take a few minutes.",
"sellMinAmount": "Minimum amount: ${amount} ${currency}",
Expand All @@ -282,10 +284,10 @@
"settingsWalletBackupSubtitle1": "Please write down your 12 recovery words in the exact order on a piece of paper and keep them in a completely safe place.",
"settingsWalletBackupSubtitle2": "This is the only way to recover your wallet.",
"showSeed": "Show Seed",
"signMessage": "Sign Message",
"signMessageGet": "Get Sign Message",
"signature": "Signature",
"signingCancelled": "Signature cancelled — please confirm on the BitBox again",
"signMessage": "Sign Message",
"signMessageGet": "Get Sign Message",
"skip": "Skip",
"softwareTermsText": "By using this app, you accept the terms of use of this software.",
"softwareTermsTextHighlighted": "terms of use",
Expand Down Expand Up @@ -329,9 +331,9 @@
"transactionBuy": "Buy",
"transactionHistory": "Transaction history",
"transactionPending": "Processing",
"transactions": "Transactions",
"transactionSell": "Sell",
"transactionWaitingForPayment": "Waiting for payment",
"transactions": "Transactions",
"twoFa": "Two-factor authentication",
"twoFaCodeRequired": "Code is required",
"twoFaCodeTooShort": "Code should be 6 digits",
Expand All @@ -356,4 +358,4 @@
"youPay": "You pay",
"youReceive": "You receive",
"youSell": "You sell"
}
}
7 changes: 7 additions & 0 deletions lib/packages/hardware_wallet/bitbox.dart
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,13 @@ class BitboxService {
if (!didVerify) throw Exception('Failed to verify');
}

/// The paired device's firmware status (`uninitialized` / `seeded` /
/// `initialized`). Read after pairing to tell a device with no wallet set up
/// (`uninitialized` — cannot derive an address) apart from a ready device.
/// Delegates to the plugin's cached-status read, so there is no device
/// round-trip and it cannot block.
Future<String> getDeviceStatus() => bitboxManager.getDeviceStatus();

/// Derives the wallet's ETH address from the device, retrying transient empty
/// reads before giving up.
///
Expand Down
67 changes: 58 additions & 9 deletions lib/screens/hardware_connect_bitbox/bloc/connect_bitbox_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,13 @@ class ConnectBitboxCubit extends Cubit<BitboxConnectionState> {
// walked away and the device-side ephemeral noise channel has died.
static const Duration _defaultPairingPinTimeout = Duration(seconds: 120);

// The bitbox02 firmware status for a device that has no wallet set up — it
// cannot derive an address. Mirrors the SDK's `StatusUninitialized`. Only this
// value is treated as "not set up": other non-ready statuses (e.g. a firmware
// upgrade requirement) are intentionally left on the existing failure path
// rather than mislabelled as unseeded.
static const _statusUninitialized = 'uninitialized';

ConnectBitboxCubit(
this._service,
this._walletService,
Expand Down Expand Up @@ -155,15 +162,18 @@ class ConnectBitboxCubit extends Cubit<BitboxConnectionState> {
'Disconnect the device, restart the app, and re-pair.',
),
);
final wallet = await _acquireWalletOrDefault().timeout(
_createWalletTimeout,
onTimeout: () => throw TimeoutException(
'BitBox did not return an ETH address within '
'${_createWalletTimeout.inSeconds}s. Try disconnecting and re-pairing.',
),
);
_service.startConnectionStatusObserver();
await _captureAuthSignature(wallet);
// A device paired without a wallet set up has no seed, so the address read
// below would come back empty and fail as a generic error — bouncing the
// user into the silent re-scan loop with no idea why. Detect it up front
// and surface a dedicated state. Returning here (instead of throwing) means
// no re-scan timer is armed, so the device isn't picked up and re-paired in
// an endless loop.
if (await _service.getDeviceStatus() == _statusUninitialized) {
if (isClosed) return;
emit(BitboxNotInitialized(currentState.device));
return;
}
await _acquireWalletAndConnect();
} catch (e) {
developer.log(e.toString(), name: '$ConnectBitboxCubit');
_pendingInit = null;
Expand All @@ -173,6 +183,45 @@ class ConnectBitboxCubit extends Cubit<BitboxConnectionState> {
}
}

/// Acquires the wallet from the device and finishes the connection. Shared by
/// the initial pairing flow and the [recheckDeviceStatus] retry so both run
/// the same create/observe/sign sequence.
Future<void> _acquireWalletAndConnect() async {
final wallet = await _acquireWalletOrDefault().timeout(
_createWalletTimeout,
onTimeout: () => throw TimeoutException(
'BitBox did not return an ETH address within '
'${_createWalletTimeout.inSeconds}s. Try disconnecting and re-pairing.',
),
);
_service.startConnectionStatusObserver();
await _captureAuthSignature(wallet);
}

/// Re-reads the device status after a [BitboxNotInitialized], for when the user
/// has set up / restored a wallet on the device and wants to continue without
/// re-pairing. If the device now reports a wallet, the connection proceeds; if
/// it is still unseeded, the state is re-emitted so the user can try again.
Future<void> recheckDeviceStatus() async {
final currentState = state;
if (currentState is! BitboxNotInitialized) return;
try {
if (await _service.getDeviceStatus() == _statusUninitialized) {
if (isClosed) return;
emit(BitboxNotInitialized(currentState.device));
return;
}
if (isClosed) return;
emit(BitboxPairing(currentState.device));
await _acquireWalletAndConnect();
} catch (e) {
developer.log(e.toString(), name: '$ConnectBitboxCubit');
if (isClosed) return;
emit(BitboxNotConnected());
_checkForTimer = Timer.periodic(const Duration(milliseconds: 500), (_) => checkForBitbox());
}
}

/// Captures and caches the auth signature as an awaited, user-guided step of
/// the pairing flow. The BitBox is guaranteed connected here, so every later
/// buy / KYC / user-data call can run off the cached signature without
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ class BitboxPairing extends BitboxFound {
BitboxPairing(super.device);
}

/// The paired BitBox has no wallet set up yet (firmware status `uninitialized`),
/// so no address can be derived. A dedicated state — not the generic failure —
/// so the UI can tell the user to set up / restore a wallet on the device first,
/// instead of bouncing through the silent re-scan loop. Carries the device so a
/// re-check can continue the connection without re-pairing.
class BitboxNotInitialized extends BitboxFound {
BitboxNotInitialized(super.device);
}

class BitboxCapturingSignature extends BitboxConnectionState {
final BitboxWallet wallet;

Expand Down
14 changes: 14 additions & 0 deletions lib/screens/hardware_connect_bitbox/connect_bitbox_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,20 @@ class ConnectBitboxView extends StatelessWidget {
],
),
),
BitboxNotInitialized() => ConnectContent(
title: S.of(context).connectBitboxNotInitializedTitle,
imagePath: 'assets/images/illustrations/bitbox_connect.svg',
onConfirm: () => context.read<ConnectBitboxCubit>().recheckDeviceStatus(),
onCancel: onCancel ?? context.pop,
confirmLabel: S.of(context).retry,
child: Text(
S.of(context).connectBitboxNotInitialized,
textAlign: .center,
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
color: RealUnitColors.neutral500,
),
),
),
BitboxCapturingSignature() => ConnectContent(
title: S.of(context).connectBitboxSignatureCapturingTitle,
imagePath: 'assets/images/illustrations/bitbox_connected.svg',
Expand Down
Loading