Page MenuHomePhabricator

[ecash-agora] Add `AgoraPartial.script` to build the Script for partial SLP offers
ClosedPublic

Authored by tobias_ruck on Tue, Sep 10, 22:59.

Details

Summary

Add a function building the SLP version of the script for offers that can be partially accepted.

This doesn't add a way of spending them yet, and tests are more to "pin" the script code (which is important, so future refactors don't change the script code), than to actually test if they work as intended. All of which will be added in a future diff.

Depends on D16735.

Test Plan

npm run test

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

add ecash-agora-tests to build

tobias_ruck retitled this revision from [ecash-agora] Add `AgoraPartial.script` to build the Script for partial offers to [ecash-agora] Add `AgoraPartial.script` to build the Script for partial SLP offers.Wed, Sep 11, 13:51
modules/ecash-agora/src/partial.ts
540 ↗(On Diff #49656)

what is intros. ?

569 ↗(On Diff #49656)

this was worked out separately right? as in, some kind of script debugger?

not sure what value there is in manually reviewing it here except for, say, typos, or if there is some condition missed in testing. everything in fromOps is ... effectively generated code?

Is it practical/possible for someone to engineer complicated scripts like this just using all of these OP_xxx variables?

how did you write this?

570 ↗(On Diff #49656)

some comments start with // #, others with just // -- is there some key distinction or is this a coincidence?

modules/ecash-agora/src/partial.ts
540 ↗(On Diff #49656)

In the case of SLP, it's the SLP SEND OP_RETURN script with one 0 token output already there (the others will be added in the script, therefore "intro").
In the case of ALP, it's the ALP SEND pushdata, but without the number of amounts (the amounts will be added in the script).

Maybe there's a better name than intro, but since it's a fixed bytestring and it's in the beginning, intro could make sense.

569 ↗(On Diff #49656)

This script was hand-written, but using my (very hard-to-use) Iguana debugger (written in TS and Rust) so I always see what's on the stack etc..

I'm not sure how we should go about reviewing this; you can try to follow what's going on in the Script, but it's going to be difficult. We can also hop on a call and I explain it, we can record it and add it to the diff for posterity.

The GNC approved a very simplified version of Iguana already, and I plan to extend it in the future, and maybe have a proper compiler in the future. But I don't think this diff should be blocked by that.

570 ↗(On Diff #49656)

Well I have this convention here that // # are plain English comments and // are more formal, as if there was a language for these opcodes. Maybe Tendo and I can build something more friendly here.

This revision is now accepted and ready to land.Wed, Sep 18, 21:27