How does Kaspa let scripts find and count authorized outputs?
Kaspa's script engine provides two dedicated opcodes — OpAuthOutputCount and OpAuthOutputIdx — that give a script dynamic visibility into which outputs a given input has authorized. OpAuthOutputCount (0xcb) takes an input index and returns how many authorized outputs exist for that input. OpAuthOutputIdx (0xcc) takes an input index and a rank number k, then returns the position of the k-th authorized output in the transaction's output list. For anyone building covenant-based Kaspa applications, this matters because scripts can discover authorized outputs at runtime rather than hard-coding positions, making covenant logic far more flexible and composable.