verify_and_sign

Function verify_and_sign 

Source
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 validation
  • input_index - Index of the input to verify and sign (0-based)
  • emulated_tx_to - Serialized transaction to verify and sign
  • actual_spent_outputs - Actual outputs being spent
  • aux_rand - Auxiliary random data for signing
  • parent_key - Parent secret key used to derive child key for signing
  • backup_merkle_root - Optional merkle root for backup script path spending

§Errors

Returns error if verification fails, key derivation fails, or signing fails