Page MenuHomePhabricator

[bip21 ecash spec] Update opreturn spec
AbandonedPublic

Authored by bytesofman on Dec 22 2023, 19:40.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Summary

Ref D15035

Initially my thinking was along the lines of: it's dumb to require 6a because it can only start with 6a. However, after working to implement a parser, this ends up creating more complication.

The URI is likely generated by code, which is likely generating a valid OP_RETURN string that starts with 6a. So we would be asking URI creators to chop it off. After that, wallet implementers need to add it back in.

Since there isn't really a byte concern about URI strings, let's just require a full valid OP_RETURN output. This is also the simplest for wallet implementation as there is no room for ambiguity in selection of push codes. What the URI creator wants the URI creator gets.

Test Plan

yay or nay on this rationale, ideally with an alt solution if nay

Diff Detail

Repository
rABC Bitcoin ABC
Branch
opreturn-bip21-update
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 26064
Build 51702: Build Diff
Build 51701: arc lint + arc unit

Event Timeline

Either way is fine with me as long as there's a good way to set and retrieve values.

For our use case, we know which addresses will have the txs ahead of time and will be reading each tx as they come in and parsing the OP_RETURN. We're flexible with how that parsing is done. It could be just 1 big string and we could work with that. It could also be broken up into an array of "things" for us to loop through. Whatever makes sense.

If there's some weird quirk that is super confusing for users but is there for technical reasons, PayButton can also act as an abstraction layer to hide it from the user.

The only standard tx format is OP_RETURN <PUSH OPCODE(s)> <DATA>. Nothing else will be accepted in a mempool or relayed. It makes no sense to let the URI contain the whole script, it's error prone and needs validation to be duplicated in the code making the transaction.
Just use a max 220 bytes, which is the data with no opcode at all and add the op_return and push opcodes in the software that creates the tx => no validation needed, it's simple and it works.

This revision is now accepted and ready to land.Dec 22 2023, 22:04
Fabien requested changes to this revision.Dec 22 2023, 22:04
This revision now requires changes to proceed.Dec 22 2023, 22:04

The only standard tx format is OP_RETURN <PUSH OPCODE(s)> <DATA>. Nothing else will be accepted in a mempool or relayed. It makes no sense to let the URI contain the whole script, it's error prone and needs validation to be duplicated in the code making the transaction.
Just use a max 220 bytes, which is the data with no opcode at all and add the op_return and push opcodes in the software that creates the tx => no validation needed, it's simple and it works.

I don't think it's so simple, since many OP_RETURN txs use multiple pushes.

Say we want a URI for an alias tx.

From the spec:

An output with an OP_RETURN containing 4 data pushes:
A push of the 4-byte protocol identifier. Must be pushed with 04.
A push of a version number. Must be pushed as OP_0.
A push of the Alias. Must be pushed with 0x01-0x15.
A push of a CashAddr payload. This information defines the "Alias Address". Must be pushed with

Here's an example: https://explorer.e.cash/tx/ec92610fc41df2387e7febbb358b138a802ac26023f30b2442aa01ca733fff7d

Here, the output script is 6a042e786563000131150076458db0ed96fe9863fc1ccec9fa2cfab884b0f6

So the URI param using OP_RETURN <PUSH OPCODE(s)> <DATA> format, where we add OP_RETURN and <PUSH OPCODE(s)>, would be ?opreturn=2e786563000131150076458db0ed96fe9863fc1ccec9fa2cfab884b0f6 ?

Dev has no easy way of knowing he needs to push this 29-byte string with 04. Maybe I'm not understanding the solution you'd like to see here.

We could support something like ... opreturn=2e786563&opreturn=0&opreturn=01&.... etc ...but this is also messy. How do we know &opreturn=0 must be a push of OP_0? What if the URI creator wanted 0x0100?

I think we need to start with a "literally this" approach. The param is just the exact hex output expected.

We don't really need to validate this at all, since the node will fail to broadcast any malformed OP_RETURN. I just like to validate stuff like this in Cashtab to catch it before bouncing it off the node.

doc/standards/bip21-ecash-additions.md
67

Are the other params case insensitive as well ?

bytesofman marked an inline comment as done.