butr
API reference

@usebutr/bitcoin

Wallet Standard discovery plus injected fallbacks, the adapter builder, and the Bitcoin feature types.

Discovery

discoverBitcoinAdapters(onAdapter): () => void

Subscribes to Wallet Standard registrations for Bitcoin wallets (Phantom, Magic Eden, Leather, …). Lazily imports @wallet-standard/app, an optional peer dependency. It is a WalletSource as-is.

discoverInjectedBitcoinAdapter(onAdapter, options?): () => void

The fallback for wallets that never announce through Wallet Standard. After settleMs it emits an adapter for each provider it finds, unless hasAnyWalletStandardAdapter() says Wallet Standard already found one:

ProviderAdapter idNameSigner kind
window.unisatinjected:bitcoin:unisatUnisatunisat
window.okxwallet.bitcoininjected:bitcoin:okxOKX Wallet (Bitcoin)unisat
window.XverseProviders.BitcoinProviderinjected:bitcoin:xverseXversesats-connect
window.btcinjected:bitcoin:legacyBrowser Bitcoin walletunisat

InjectedBitcoinDiscoveryOptions: hasAnyWalletStandardAdapter?: () => boolean, settleMs?: number (default 150), target? (overrides window).

bitcoinDiscoverer: PlatformDiscoverer

Wallet Standard as the primary channel, the injected adapters as the fallback. autoDiscovery(["bitcoin"]) from @usebutr/wallets wires both.

Adapter builder

buildBitcoinAdapter(wallet, registerDisconnector?): BitcoinAdapter | null

Wraps a WalletStandardWallet, or returns null when it speaks no Bitcoin. The id is slugify("btc", wallet.name). Each optional method exists only when the wallet advertises its feature:

MethodFeatureResolves
sendTxbitcoin:sendTransferThe txid.
signMessagebitcoin:signMessage{ signature, signedMessage }.
signTransactionbitcoin:signPsbtThe signed PSBT bytes.

sendTx takes a BitcoinTransfer ({ amount, recipient }, satoshis); signTransaction takes PSBT bytes. The Bitcoin connector covers the injected adapters, which switch or refuse a network instead of routing it per call.

Signers

Wallet Standard adapters resolve { kind: "wallet-standard", wallet }. Importing the package registers the injected kinds:

  • unisat: { provider }, the UniSat-style provider the adapter drives.
  • sats-connect: { provider }, Xverse's request(method, params) provider.

Constants

GENERIC_BITCOIN_ICON: the injected adapters' icon.

Types

BitcoinSignMessageFeature, BitcoinSignMessageInput, BitcoinSignMessageOutput, BitcoinSignPsbtFeature, BitcoinSignPsbtInput, BitcoinSignPsbtOutput, BitcoinSendTransferFeature, BitcoinSendTransferInput, BitcoinSendTransferOutput, InjectedBitcoinDiscoveryOptions.

The Bitcoin chain registry (BITCOIN_CHAINS, BITCOIN_CHAINS_LIST) lives in @usebutr/core.

Source: packages/bitcoin/src/index.ts.