serai-dex / serai

Other
260 stars 47 forks source link

Support input-encoded instructions #258

Closed kayabaNerve closed 7 months ago

kayabaNerve commented 1 year ago

Ordinals encode data on Bitcoin by creating a P2TR output, then in the revealed scripts, including PUSH FALSE, IF, PUSH *data*, ELSE, CHECK SIG (roughly). This has no limit (OP_RETURN has an 80-byte limit) and takes advantage of the discount applied to witness data. Serai can support a similar method for its instructions.

I will note ordinals are contentious. SegWit data is prunable, so it's undeniably healthier than OP_RETURN (in my opinion). The main concern is BTC advocates may ban ordinals. In order to not get banned, which would likely be done by banning scripts with IF FALSEs, we'd likely need to have a script where the data segment is a potential spend path (if a hash preimage is provided). Serai clients would then make up a hash with no known preimage (and till requiring a CHECK SIG).

While this does require creating a leading transaction, to then spend with the instruction encoded in the input, Bitcoin supports TX chaining so there shouldn't be a time delay on this. As long as the second TX is the one sending to Serai, there's also no risk of failing the data availability problem.

kayabaNerve commented 1 year ago

This will be necessary in order to perform BTC -> XMR swaps post-Seraphis, as JAMTIS addresses exceed 80 bytes.