
signPsbt
Request the signature and broadcast of a Partially Signed Bitcoin Transaction (PSBT)
Method name
signPsbt
Parameters
hex
Hex of PSBT payload for signing
string
allowedSighash
Sighash types allowed for signing and finalizing inputs (defaults to type ALL)
SignatureHash[]
signAtIndex
Input index(es) that should be signed (defaults to sign all inputs)
number | number[]
network
Network for signing: mainnet, testnet, signet, sbtcDevenv or devnet
string
account
Index of account for signing (defaults to active account)
uint
broadcast
Whether to broadcast upon signing (default false). txidreturned on successful broadcast.
boolean
Example request
Sign PSBT
interface SignPsbtRequestParams {
hex: string;
allowedSighash?: SignatureHash[];
signAtIndex?: number | number[];
network?: NetworkModes; // default is user's current network
account?: number; // default is user's current account
broadcast?: boolean; // default is false - finalize/broadcast tx
}
const requestParams: SignPsbtRequestParams = { ...params };
const response = await window.LeatherProvider.request('signPsbt', requestParams);Broadcast PSBT
Our API returns a PSBT back to the app, with the newly applied signatures. If your use-case is to spend the transaction immediately, you'll first need to finalize it, then broadcast it to the network.
See this example below how to extract a signed transaction from the PSBT
Types and helper functions
Helper functions for Native SegWit PsbtRequestOptions
PsbtRequestOptionsHelper functions for Taproot PsbtRequestOptions
PsbtRequestOptionsCustom scripts
For more complex PSBTs, such as those using custom Bitcoin scripts, we recommend you read the supporting documentation of the @scure/btc-signer library.
Debugging
If you're running into issues signing a PSBT with Leather, the best way to debug the problem is to sign it without Leather.
Starting with a test-only mnemonic, drive a BTC address, and try sign the transaction. This helps ensure your PSBT is constructed correctly.
Here's a Codesandbox with a PSBT debugging environment set up for you to test. When asking for PSBT signing support, provide a test case forked from this.
Preview

Last updated