pub fn verify_and_sign<V: Verifier>(
verifier: &V,
input_index: usize,
emulated_tx_to: &[u8],
actual_spent_outputs: &[TxOut],
aux_rand: &[u8; 32],
parent_key: SecretKey,
backup_merkle_root: Option<TapNodeHash>,
) -> Result<Transaction, Error>Expand description
Verifies an emulated Bitcoin script and signs the corresponding transaction.
This function performs script verification using bitcoinkernel, verifying an
emulated P2TR input. If successful, it derives an XOnlyPublicKey from the
parent key and the emulated merkle root, which is then tweaked with an optional
backup merkle root to derive the actual spent UTXO, which is then key-path signed
with SIGHASH_DEFAULT.
If the emulated script-path spend includes a data-carrying annex (begins with 0x50 followed by 0x00), the annex is included in the key-path spend. Otherwise, the annex is dropped.
§Arguments
verifier- The verifier to use for script validationinput_index- Index of the input to verify and sign (0-based)emulated_tx_to- Serialized transaction to verify and signactual_spent_outputs- Actual outputs being spentaux_rand- Auxiliary random data for signingparent_key- Parent secret key used to derive child key for signingbackup_merkle_root- Optional merkle root for backup script path spending
§Errors
Returns error if verification fails, key derivation fails, or signing fails