Get Signatures
Similar to signing messages, Panda Wallet can also getSignatures
for a raw transaction.
It may look something like:
const wallet = initProvider(); // see "Detecting the Provider"
try {
const sigRequests: SignatureRequest[] = [
{
prevTxid: // txid string,
outputIndex: 0,
inputIndex: 0,
satoshis: 1,
address: // ordAddress string,
},
{
prevTxid: // txid string,
outputIndex: 0,
inputIndex: 1,
satoshis: 1000,
address: // bsvAddress string,
script: // script as hex string
}
];
const sigResponses: SignatureResponse[] = await wallet.getSignatures({
rawtx: // unsignedTxRawHex string,
sigRequests
});
// See types below for response
} catch (err) {
console.log(err);
}
Types:
/**
* `SignatureRequest` contains required informations for a signer to sign a certain input of a transaction.
*/
export interface SignatureRequest {
prevTxid: string;
outputIndex: number;
/** The index of input to sign. */
inputIndex: number;
/** The previous output satoshis value of the input to spend. */
satoshis: number;
/** The address(es) of corresponding private key(s) required to sign the input. */
address: string | string[];
/** The previous output script of input, default value is a P2PKH locking script for the `address` if omitted. */
script?: string;
/** The sighash type, default value is `SIGHASH_ALL | SIGHASH_FORKID` if omitted. */
sigHashType?: number;
/**
* Index of the OP_CODESEPARATOR to split the previous output script at during verification.
* If undefined, the whole script is used.
* */
csIdx?: number;
/** The extra information for signing. */
data?: unknown;
}
/**
* `SignatureResponse` contains the signing result corresponding to a `SignatureRequest`.
*/
export interface SignatureResponse {
/** The index of input. */
inputIndex: number;
/** The signature.*/
sig: string;
/** The public key bound with the `sig`. */
pubKey: string;
/** The sighash type, default value is `SIGHASH_ALL | SIGHASH_FORKID` if omitted. */
sigHashType: number;
/** The index of the OP_CODESEPARATOR to split the previous output script at.*/
csIdx?: number;
}
Last updated