signTransaction
To request signing of a PSBT, you can use the signTransaction
function.
The PSBT to be signed must be base64-encoded. You can use any Bitcoin library to construct this transaction. See examples using @scure/btc-signer
here: Creating PSBTs
payload | Description |
---|---|
network | an object specifying the target Bitcoin chain (Mainnet / Testnet) |
psbtBase64 | a valid |
broadcast | a flag that specifies whether to broadcast the signed transaction |
inputsToSign | an array of objects describing the address and index of input to sign |
Your request must specify
The index of the input to sign
which address to use to sign the input
For example:
The above parameters will ask the wallet to sign for address bc1pr09enf3yc43cz8qh7xwaasuv3xzlgfttdr3wn0q2dy9frkhrpdtsk05jqq
at input index 0. And for address 33TKH4kkiFPyTLDNmdNsLggyLeAYre57Qm
at input indexes 1 and 2.
You can also optionally specify a signature hash:
Depending on your use case, you can request that the PSBT be finalized and broadcasted after the user signs, by setting the payload's broadcast flag to true. Otherwise, the signed PSBT will be returned in the response without broadcasting.
If the transaction is broadcasted, you will receive a TXID in the response.
Last updated