signPsbts
signPsbts
Sign multiple PSBTs at once. This method will traverse all inputs that match the current address to sign.
Wallet & Address Type Compatibility
Software Wallet
All
p2wpkh (Native Segwit), p2tr (Taproot)
Hardware Wallet
Pro, Classic1S
p2tr (Taproot)
Method
async function signPsbts(
psbtHexs: string[],
options?: {
autoFinalized?: boolean;
toSignInputs?: Array<{
index: number;
address?: string;
publicKey?: string;
sighashTypes?: number[];
useTweakedSigner?: boolean;
}>;
},
): Promise<string[]>Parameters
psbtHexs— requiredstring[]Array of hex strings of PSBTs to signoptions— optionalobjectautoFinalized— optionalbooleanWhether to finalize PSBTs after signing, default istruetoSignInputs— optionalarraySpecify which inputs to signindex— requirednumberWhich input to signaddress— optionalstringWhich corresponding private key to use for signing (specify either address or publicKey)publicKey— optionalstringWhich corresponding private key to use for signing (specify either address or publicKey)sighashTypes— optionalnumber[]Optional sighash typesuseTweakedSigner— optionalbooleanForce whether to use tweaked signer, has higher priority than disableTweakSigner
Returns
Promise<string[]>Array of hex strings of signed PSBTs
Example
const provider = (window.$onekey && window.$onekey.btc) || window.unisat;
try {
const psbtHexs = [
"70736274ff01007d...",
"70736274ff01007d..."
];
const signeds = await provider.signPsbts(psbtHexs, {
autoFinalized: true,
toSignInputs: [{
index: 0,
publicKey: "02abc...",
useTweakedSigner: true
}]
});
console.log(signeds);
} catch (e) {
console.log(e);
}Demo
Last updated
Was this helpful?