Checking if a wallet is a Bitcoin wallet
You can use theisBitcoinWallet helper method to check if a wallet is a Bitcoin wallet. That way, TypeScript will know which methods are available to you.
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
🚀 Stablecoin Accounts are live! Learn more
isBitcoinWallet helper method to check if a wallet is a Bitcoin wallet. That way, TypeScript will know which methods are available to you.
import { isBitcoinWallet } from '@dynamic-labs/bitcoin';
if (!isBitcoinWallet(wallet)) {
throw new Error('This wallet is not a Bitcoin wallet');
}
const result = wallet.sendBitcoin({
amount: 100000000n,
recipientAddress: 'SOME-ADDRESS',
});
| Method | Description |
|---|---|
| sendRawTransaction(rawTransactionHex: string): Promise<string | undefined> | This method submits a raw transaction to the bitcoin blockchain and returns the transaction ID as the response |
| sendBitcoin(transaction: BitcoinTransaction): Promise<string | undefined> | A method to send an amount of satoshis to a recipient bitcoin address |
| signMessage(messageToSign: string, { addressType: WalletAddressType, protocol: BitcoinSignProtocol }): Promise<string\ | undefined> | Signs a message with a specific bitcoin address type (‘ordinals’ or ‘payment’) and/or protocol (‘ecdsa’ or ‘bip322-simple’) |
| signPsbt(request: BitcoinSignPsbtRequest): Promise<BitcoinSignPsbtResponse | undefined> | Signs a PSBT and returns an object with the signed PSBT |
| signPsbts(request: BitcoinSignPsbtRequest[]): Promise<string[] | undefined> | Signs a list of PSBTs and returns an array of signed PSBTs in base64 |
type BitcoinSignPsbtRequest = {
allowedSighash: number[];
unsignedPsbtBase64: string;
signature?: {
address: string;
signingIndexes: number[] | undefined;
disableAddressValidation?: boolean; // helpful for multi-sig
}[];
};
type BitcoinTransaction = {
amount: bigint;
recipientAddress: string;
}
type WalletAddressType = 'payment' | 'ordinal';
type WalletAdditionalAddress {
address: string;
publicKey?: string;
type: WalletAddressType;
}
type BitcoinSignPsbtResponse = {
signedPsbt: Psbt; // see reference below for what a PSBT is
};
1 Bitcoin = 100,000,000 Satoshis
Was this page helpful?