signPsbts
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
| Parameter | Type | Description |
|---|
requests | BitcoinSignPsbtRequest[] | Array of PSBT signing requests |
requests[].unsignedPsbtBase64 | string | The unsigned PSBT encoded in Base64 |
requests[].allowedSighash | number[] | Array of allowed signature hash types |
requests[].signature | Array (optional) | Array of signature configuration objects |
walletAccount | BitcoinWalletAccount | The wallet account to sign with |
client | DynamicClient (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
| Error | Description |
|---|
NotBitcoinProviderError | Thrown if the wallet account’s provider is not a Bitcoin provider |
Last modified on January 26, 2026