Skip to content

feat: minimal sweep WIF QR-code implementation#53

Open
psychemist wants to merge 5 commits intobitcoindevkit:variant/2.0from
psychemist:feat/wif-sweep-qrcode
Open

feat: minimal sweep WIF QR-code implementation#53
psychemist wants to merge 5 commits intobitcoindevkit:variant/2.0from
psychemist:feat/wif-sweep-qrcode

Conversation

@psychemist
Copy link
Copy Markdown

@psychemist psychemist commented Apr 22, 2026

Description

This PR adds the ability to sweep funds from an external WIF private key into the user's wallet by scanning a QR code or copy-pasting the raw WIF string.

What This Does

  • Scan a QR code containing a WIF private key (or type/paste it manually)
  • App derives all standard address types (wpkh, pkh, tr, sh-wpkh) from the key, scans each for funds, and sweeps any balance into the user's wallet
  • Supports mainnet (K/L/5) and testnet (c/9) WIF formats
  • Accepts raw WIF, wif: prefix, and bitcoin:?wif= URI formats

Flow

  • Send screen → "Sweep WIF" button → QR scanner dialog
  • Scanned value parsed by WifParser.extract() and validated
  • SendViewModel dispatches TransactionType.SWEEP on IO thread
  • Wallet.sweep() iterates over descriptors, fully scans each via Esplora, and drains any with balance (confirmed + unconfirmed)
  • Success/error toast via existing broadcastResult state flow

Testing

  1. Unit tests (JVM, no device needed)
    ./gradlew :app:testDebugUnitTest

  2. Install on device/emulator
    ./gradlew installDebug

  3. Manual: send testnet4 coins to the wpkh address derived from a test WIF then sweep. Check in-app logs for balance details per descriptor.
    Check out test sweep transaction on testnet4 here:

Screenshots IMG_6321 IMG_6322 Screenshot_20260418-180945 Screenshot_20260418-181206

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