Skip to main content
Signs multiple Partially Signed Bitcoin Transactions (PSBTs) in a single operation. This is useful for batch operations or when working with multiple transactions that need to be signed together.

Usage

import { signPsbts, isBitcoinWalletAccount } from '@dynamic-labs-sdk/bitcoin';
import { getPrimaryWalletAccount } from '@dynamic-labs-sdk/client';

const walletAccount = getPrimaryWalletAccount();

if (walletAccount && isBitcoinWalletAccount(walletAccount)) {
  const { signedPsbts } = await signPsbts({
    walletAccount,
    requests: [
      {
        unsignedPsbtBase64: 'cHNidP8BAH...',
        allowedSighash: [1],
        signature: [
          {
            address: walletAccount.address,
            signingIndexes: [0],
          },
        ],
      },
      {
        unsignedPsbtBase64: 'cHNidP8BAI...',
        allowedSighash: [1],
        signature: [
          {
            address: walletAccount.address,
            signingIndexes: [0, 1],
          },
        ],
      },
    ],
  });

  console.log('Signed PSBTs:', signedPsbts);
}

Parameters

ParameterTypeDescription
requestsBitcoinSignPsbtRequest[]Array of PSBT signing requests
requests[].unsignedPsbtBase64stringThe unsigned PSBT encoded in Base64
requests[].allowedSighashnumber[]Array of allowed signature hash types
requests[].signatureArray (optional)Array of signature configuration objects
walletAccountBitcoinWalletAccountThe wallet account to sign with
clientDynamicClient (optional)The Dynamic client instance. Only required when using multiple clients.

Returns

Promise<{ signedPsbts: string[] }> - A promise that resolves to an object containing an array of signed PSBTs in Base64 format.

Errors

ErrorDescription
NotBitcoinProviderErrorThrown if the wallet account’s provider is not a Bitcoin provider