Skip to Content
dApps
On this page

signPsbts

Sign multiple PSBTs at once. This method will traverse all inputs that match the current address to sign.

Wallet & Address Type Compatibility

Wallet TypeModelAddress Types Supported
Software WalletAllp2wpkh (Native Segwit), p2tr (Taproot)
Hardware WalletPro, Classic1Sp2tr (Taproot)

Method

declare function signPsbts( psbtHexs: string[], options?: { autoFinalized?: boolean; toSignInputs?: Array<{ index: number; address?: string; publicKey?: string; sighashTypes?: number[]; disableTweakSigner?: boolean; useTweakedSigner?: boolean; }>; }, ): Promise<string[]>

Parameters

  • psbtHexs — required string[] Array of hex strings of PSBTs to sign
  • options — optional object
    • autoFinalized — optional boolean Whether to finalize PSBTs after signing, default is true
    • toSignInputs — optional array Specify which inputs to sign
      • index — required number Which input to sign
      • address — optional string Which corresponding private key to use for signing (specify either address or publicKey)
      • publicKey — optional string Which corresponding private key to use for signing (specify either address or publicKey)
      • sighashTypes — optional number[] Optional sighash types
      • disableTweakSigner — optional boolean Default is false. Set true to use original private key when signing Taproot inputs
      • useTweakedSigner — optional boolean Force whether to use tweaked signer; higher priority than disableTweakSigner

Returns

  • Promise<string[]> Array of hex strings of signed PSBTs

Example

const provider = (window.$onekey && window.$onekey.btc) || window.unisat; try { const psbtHexs = [ "70736274ff01007d...", "70736274ff01007d..." ]; const signeds = await provider.signPsbts(psbtHexs, { autoFinalized: true, toSignInputs: [ { index: 0, publicKey: "02abc...", useTweakedSigner: true }, { index: 1, address: "bc1p...", disableTweakSigner: true } ] }); console.log(signeds); } catch (e) { console.log(e); }

Demo

The abbreviated values are placeholders. Replace them with complete PSBTs, addresses, and public keys. The published provider interface exposes autoFinalized; advanced input options depend on the wallet implementation and should be verified against the target version. Signing does not broadcast a transaction.

Last updated on