validation/count
This module contains code to accurately count the number of inputs and outputs in a transaction containing an address or a datum.
Functions
Verify that the number of inputs with an inline datum or datum hash is equal to the number intended in the contract. The amount must be exactly the counter.
count.inputs_by_datum(tx.inputs, 1)
Count the number of inputs with a payment credential that is a script. This does not take in an address but is a general count of validator hashes.
count.inputs_by_vkh(tx.inputs, 1)
Count the number of outputs with a payment credential that is a script. This does not take in an address but is a general count of validator hashes.
count.outputs_by_vkh(tx.outputs, 1)
Verify that the number of inputs from a specific script is equal to the amount intended in the contract. The amount must be exactly the counter.
count.inputs_by_addr(tx.inputs, this_addr, 1)
Verify that the number of outputs from a specific script is equal the amount intended in the contract. The amount must be exact with the counter.
count.outputs_by_addr(tx.outputs, this_addr, 1)
Verify that the number of outputs with an inline datum or datum hash is equal to the number intended in the contract. The amount must be exactly the counter.
count.outputs_by_datum(tx.outputs, 1)
single_input_with_bypass(
inputs: List<Input>,
this_addr: Address,
those_addrs: List<Address>,
) -> Bool
The contract can only be spent by itself or along side some list of know addresses. Loop all the inputs and count how many datums belong to this address. If any of those addresses exists then pass right over them but if anything else is found then fail. This should prevent unregulated contracts from being spent along side this script.
count.single_input_with_bypass(this_tx.inputs, this_addr, [that_addr])