pub fn verify_and_sign<V: Verifier>(
verifier: &V,
emulated_tx_to: &Transaction,
actual_spent_outputs: &[TxOut],
aux_rand: &[u8; 32],
parent_key: SecretKey,
backup_merkle_roots: HashMap<usize, TapNodeHash>,
) -> Result<Transaction, Error>Expand description
Verifies emulated Bitcoin script and signs the corresponding transaction.
This function performs script verification using a Verifier, which verifies one or
more emulated P2TR inputs. If successful, it derives for each emulated input an
XOnlyPublicKey from the parent key and the emulated merkle root, which is then tweaked
with an optional backup merkle root to derive the input’s actual spent UTXO. This 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.
Non-emulated inputs are identified by the input type. An emulated input must be a P2TR script-path spend, with a derived scriptPubKey that does not match that of the actual spent output.
Each signature uses a unique aux_rand by hashing the provided aux_rand with the
index of the input, using SHA256.
§Arguments
verifier- The verifier to use for script validationemulated_tx_to- Emulated 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_roots- Optional merkle roots for backup script path spending
§Errors
Returns error if verification fails, key derivation fails, or signing fails