Skip to main content
Signs a message with custom options, allowing you to specify the address type and signing protocol. This is useful when you need more control over the signing process than the standard signMessage function provides.

Usage

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

const walletAccount = getPrimaryWalletAccount();

if (walletAccount && isBitcoinWalletAccount(walletAccount)) {
  const { signature } = await signMessageWithCustomOptions({
    walletAccount,
    message: 'Hello, Bitcoin!',
    addressType: 'payment', // or 'ordinals'
    protocol: 'ecdsa', // or 'bip322-simple'
  });

  console.log('Signature:', signature);
}

Parameters

ParameterTypeDescription
messagestringThe message to sign
walletAccountBitcoinWalletAccountThe wallet account to sign with
addressType'ordinals' | 'payment' (optional)The address type to use for signing
protocol'ecdsa' | 'bip322-simple' (optional)The signing protocol to use
clientDynamicClient (optional)The Dynamic client instance. Only required when using multiple clients.

Address types

  • payment - Use the standard payment address
  • ordinals - Use the ordinals (inscriptions) address

Protocols

  • ecdsa - Standard ECDSA signature
  • bip322-simple - BIP-322 simple signature format
Note: If the wallet provider does not support specifying an address type or protocol, it will use the default values.

Returns

Promise<{ signature: string }> - A promise that resolves to an object containing the signature.

Errors

ErrorDescription
NotBitcoinProviderErrorThrown if the wallet account’s provider is not a Bitcoin provider
MethodNotImplementedErrorThrown if the wallet provider does not implement the signMessage method