BigBlocks

Lock BSV

Time-lock BSV until a future block height with lock form, lock summary, and unlock for matured locks

Empty State

Installation

bunx shadcn@latest add https://registry.bigblocks.dev/r/lock-bsv.json

Usage

LockBsv requires onLock and onUnlock callbacks that perform the actual lock/unlock transactions. Wire these to @1sat/actions lock operations.

import { LockBsv } from "@/components/blocks/lock-bsv"
import { lockBsv, unlockBsv, createContext } from "@1sat/actions"
import { useWallet } from "@1sat/react"
 
export function WalletLocks() {
  const { wallet } = useWallet()
  const ctx = createContext(wallet)
 
  return (
    <LockBsv
      onLock={(params) =>
        lockBsv.execute(ctx, { requests: [params] })
      }
      onUnlock={() => unlockBsv.execute(ctx)}
      onSuccess={(result) => console.log("txid:", result.txid)}
      onError={(err) => console.error(err)}
    />
  )
}

Props

LockBsv

PropTypeDefaultDescription
lockData{ totalLocked: number; unlockable: number; nextUnlock: number }--Pre-populated lock summary data
onLock(params: { satoshis: number; until: number }) => Promise<LockOperationResult>--Callback to execute the lock transaction
onUnlock() => Promise<LockOperationResult>--Callback to unlock matured locks
onSuccess(result: LockOperationResult) => void--Called after a successful lock or unlock
onError(error: Error) => void--Called on error
classNamestring--Additional CSS classes

LockOperationResult

interface LockOperationResult {
  txid?: string
  error?: string
}