BigBlocks
Sweep Wallet
Import assets from a WIF private key into your connected wallet.
Installation
bunx shadcn@latest add https://registry.bigblocks.dev/r/sweep-wallet.jsonUsage
SweepWallet provides a full WIF-input, scan, preview, and sweep flow. Supply onScan and onSweep callbacks wired to your wallet backend.
import { SweepWallet } from "@/components/blocks/sweep-wallet"
export function ImportWallet() {
return (
<SweepWallet
onScan={async (wif) => {
// Scan the WIF for spendable UTXOs, ordinals, and tokens
const pk = PrivateKey.fromWif(wif)
const address = pk.toPublicKey().toAddress()
return await scanAddressUtxos(services, address)
}}
onSweep={async (wif, assets) => {
// Sweep all found assets into the connected wallet
const inputs = await prepareSweepInputs(ctx, assets.funding)
return await sweepBsv.execute(ctx, { inputs, wif })
}}
onSuccess={(result) => console.log("Swept:", result.txid)}
onError={(err) => console.error(err)}
/>
)
}Props
SweepWallet
| Prop | Type | Default | Description |
|---|---|---|---|
onScan | (wif: string) => Promise<ScanResult> | required | Scan a WIF for spendable assets |
onSweep | (wif: string, assets: ScanResult) => Promise<SweepResult> | required | Execute the sweep transaction |
onSuccess | (result: SweepResult) => void | -- | Called after a successful sweep |
onError | (error: Error) => void | -- | Called on error |
className | string | -- | Additional CSS classes |
ScanResult
interface ScanResult {
funding: SweepFundingUtxo[]
ordinals: SweepOrdinalUtxo[]
tokens: SweepTokenGroup[]
totalSats: number
}SweepResult
interface SweepResult {
txid?: string
error?: string
}