OP_PAIRCOMMIT as a candidate for addition to LNhance

Not really seeing that as particularly important to minimise, personally; the difference between hashing 64 bytes and 256 bytes is pretty minor, compared to the checksig operation(s) you also have. I’d just write [BAL] [CTVHASH] SHA256 SWAP SHA256 CAT SHA256.

This seems as much an argument against doing upgradeability that way as anything else; but if you do want that, and want to minimise hashing as well for whatever reason, then writing [BAL] [CTVHASH] SIZE 32 EQUALVERIFY CAT SHA256 seems like it would solve the problem.

If you want to support CTV upgradeability prior to knowing what that upgradeability will do, you could do [BAL] [CTVHASH] SIZE DUP VERIFY DUP 127 LESSTHANOREQUAL VERIFY SWAP CAT SWAP CAT SHA256 to construct sha256(1B: <size(CTVHASH)>; 0B-127B: <CTVHASH>; <BAL>). (Having CTV error if the hash is 0 bytes would let you avoid the DUP VERIFY step and might be a reasonable update to the BIP)

1 Like