Wallet adapter

Implement four methods and any BCH wallet can create and fund intents through the SDK.

The BCHSigner interface

export interface BCHSigner {
  /** Connected wallet's cashaddr, e.g. bchtest:qq… */
  getAddress(): Promise<string>;
  /** 20-byte public key hash, used in covenant constructor args. */
  getPkh(): Promise<Uint8Array>;
  /** Full public key, for signing and verification. */
  getPublicKey(): Promise<Uint8Array>;
  /** Send BCH (and optionally a CashToken) — used to fund intent covenants. */
  send(toAddress: string, satoshis: bigint, token?: { category: string; amount: bigint }): Promise<string>;
}

Built-in adapters

Adapter Use it for
MainnetJSAdapter Node scripts, bots and tests using a mainnet-js wallet
EmbeddedWalletAdapter Wallets embedded in your app
WalletConnectAdapter Browser dapps talking to mobile wallets (Cashonize, Paytaca…)
WizardConnectAdapter WizardConnect-compatible wallets

Warning: Funding covenants A generic send() to a P2SH32 address can produce the wrong output script with some libraries. When you implement send for covenant funding, build the output from the covenant's locking bytecode and check it before broadcasting.

To document