Skip to content

feat: add trezor send and receive - #1187

Open
ben-kaufman wants to merge 2 commits into
masterfrom
feat/trezor-send
Open

feat: add trezor send and receive#1187
ben-kaufman wants to merge 2 commits into
masterfrom
feat/trezor-send

Conversation

@ben-kaufman

Copy link
Copy Markdown
Contributor

Description

This PR:

  1. Adds paired Trezor wallets as funding sources throughout the normal on-chain Send flow, including scanner, paste, manual entry, contacts, fee selection, confirmation, signing, broadcasting, and success handling.
  2. Adds Trezor receive addresses with copyable QR details and verification on the device.
  3. Hardens Trezor session recovery and preserves hardware-wallet activity and contact metadata while wallet snapshots catch up.

The Send and Receive UI follows the Bitkit Wallet design.

Preview

QA Notes

Manual Tests

  • 1. Trezor wallet → Send → enter a Bitcoin address and amount → Continue: the button loads once, Confirm opens, and repeated taps do not duplicate preparation.
  • 2. Send Confirm → choose Trezor → Sign With Device → approve on Trezor: the transaction broadcasts and Success shows the hardware-wallet activity.
  • 3. Trezor wallet → Receive → Verify on Device: the QR address matches the address shown by Trezor.
  • 4. Trezor passphrase wallet → Send or Receive verification → enter passphrase: the paired account reconnects and the operation resumes.
  • 5. Trezor-funded Send → scan a Lightning or LNURL request: Bitkit explains that a Bitcoin address is required.
  • 6. regression: Send → switch between Savings, Spending, and Trezor: available balance and fee-aware maximum update for each source.
  • 7. regression: cancel or disconnect during signing → retry: Bitkit reconnects without creating or broadcasting a duplicate transaction.

Automated Checks

  • Unit tests added in HwSendViewModelTest.kt and HwReceiveViewModelTest.kt: cover signing, passphrases, stale-session retry, safe broadcast retry, result retention, address loading, and device verification.
  • Unit tests extended in AppViewModelSendFlowTest.kt, HwWalletRepoTest.kt, and TrezorRepoTest.kt: cover source selection, duplicate preparation, fee-aware maximums, offline composition, and session cleanup.
  • Unit tests extended in CoreServiceTest.kt, TransferViewModelTest.kt, TrezorExceptionExtTest.kt, and ReceiveInvoiceUtilsTest.kt: cover activity reconciliation, transfer retry, session classification, and hardware receive QR content.
  • The full dev-debug unit suite and detekt passed after the feature changes; diff checks pass.

@greptile-apps

greptile-apps Bot commented Aug 26, 2026

Copy link
Copy Markdown

Greptile Summary

The PR integrates paired Trezor wallets into on-chain send and receive flows and strengthens session recovery and hardware-activity reconciliation.

  • Adds offline fee composition, device signing, safe broadcast retry, and hardware-funded send navigation.
  • Adds hardware receive-address display and on-device verification.
  • Extends wallet-scoped activity and contact handling for hardware transactions.
  • Two lifecycle gaps remain around multi-wallet receive selection and restart-safe activity reconciliation.

Confidence Score: 3/5

The PR should not merge until multi-wallet receive selection and restart-safe preservation of newly broadcast hardware activities are addressed.

Global Receive silently loses Trezor access for users with multiple paired identities, and process-local snapshot protection can delete a newly created hardware-send activity and its contact metadata after an app restart.

Files Needing Attention: app/src/main/java/to/bitkit/ui/screens/wallets/receive/ReceiveSheet.kt; app/src/main/java/to/bitkit/services/CoreService.kt

Important Files Changed

Filename Overview
app/src/main/java/to/bitkit/ui/screens/wallets/receive/ReceiveSheet.kt Wires hardware address loading and verification into Receive, but removes the hardware option from global Receive when multiple paired wallets require selection.
app/src/main/java/to/bitkit/services/CoreService.kt Preserves locally created sends during watcher lag only through process-local state, allowing restart-time deletion and contact loss.
app/src/main/java/to/bitkit/ui/screens/wallets/send/HwSendViewModel.kt Adds a guarded sign-and-broadcast state machine with signed-transaction reuse for connectivity retries and wallet-scoped result persistence.
app/src/main/java/to/bitkit/repositories/HwWalletRepo.kt Adds offline receive derivation, device verification, fee estimation, maximum calculation, and more targeted stale-session cleanup.
app/src/main/java/to/bitkit/viewmodels/AppViewModel.kt Extends request validation, amount limits, fee preparation, source switching, contact preparation, and success handling for hardware-funded sends.
app/src/main/java/to/bitkit/repositories/ActivityRepo.kt Scopes hardware activity lookup and contact mutation to the selected external wallet identity.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Select paired Trezor] --> B[Enter on-chain request]
  B --> C[Estimate fee from stored xpub]
  C --> D[Review payment]
  D --> E[Reconnect matching wallet identity]
  E --> F[Sign on Trezor]
  F --> G[Broadcast signed transaction]
  G --> H[Create wallet-scoped activity]
  H --> I[Reconcile watcher snapshot]
  J[Open Trezor Receive] --> K[Derive unused address from xpub]
  K --> L[Display QR and address]
  L --> M[Reconnect matching identity]
  M --> N[Verify address on device]
Loading

Reviews (1): Last reviewed commit: "feat: add trezor send and receive" | Re-trigger Greptile

Comment thread app/src/main/java/to/bitkit/services/CoreService.kt Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant