HomePhabricator

[ecash-agora] Add `AgoraOneshot`

Description

[ecash-agora] Add AgoraOneshot

Summary:
This is a simplified Agora offer which can only be accepted in "one shot", e.g. all or nothing. This is useful for offers that offer exactly one token, especially NFTs.

The covenant is reasonably simple, see this article for an explanation of the covenant mechanism, but uses two optimizations:

  1. It uses ANYONECANPAY as sighash for the "accept" path, which makes the sighash preimage start with 2000....00000, which can be created with OP_2 68 OP_NUM2BIN, saving around 64 bytes.
  2. It uses OP_CODESEPARATOR before the OP_CHECKSIG, which cuts out the entire script code, leaving only the OP_CHECKSIG behind. The scriptCode part in the BIP143 sighash now just becomes 01ac, which is both easier to deal with in the OP_SPLIT and also saves 100 bytes or so (depending on the enforced outputs).

Note: This currently doesn't add any functionality for discovering trades on the blockchain, which will be done in a future diff.

Depends on D16081.

Test Plan:
BUILD_DIR=../../build npm run integration-tests

  1. For understanding the covenant:
  2. Install meep
  3. Run the accept tx of the final tx to see how it works in meep (ignore the buggy sig density check of meep):
~/meep/bin/go debug -t
01000000021f236483a002f7613f13da431e08ef6297350969ad1d2522766789b6a68d198801000000fd95012102466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f2740e1d5d9bb0b6e4ca21db777709863933706be84057b36a4f6225ce4ceaaf925044531e9c694ed850d2a010cd882fa0ec4ed1fddeae8661aa5ede1a09fea829bcd4c5a1f236483a002f7613f13da431e08ef6297350969ad1d2522766789b6a68d19880100000001ac2202000000000000ffffffff4fae5c27fc0ba6b8fdf7bc7fe8a6f135c5821bb1f79c275f5554d9d8b8bbe70900000000c10000002222020000000000001976a914531260aa2a199e228c537dfa42c82bea2c7c1f4d88ac514cb0634c6b0000000000000000406a04534c500001410453454e4420da400de527913c3bac117ef8dcc01c05439e9ebea95fe4cd339757ddf3206c9808000000000000000008000000000000000180380100000000001976a914fc7250a211deddc70ee5a2738de5f07817351cef88ac7c7eaa7801327f7701207f7588510144807c7ea86f7bbb7501c17e7c6721034f355bdcb7cc0af728ef3cceb9615d90684bb5b2ca5f859ab0f0b704075871aa68abacffffffff9f968972c1dce000a0d0c4fe781431df265117fdfec6bc4f39333f90df5bab25000000006441d1375981ee3e3e7fece31bc6cd2e5efe26ee5a082cfcd28ce3b97490ae4e3e66d4d9a79cb2eeabe92404ed20943e883e4974e658409e6c390fceee17b72b3b08412102466d7fcae563e5cb09a0d1870bb580344804617879a14949cf22285f1bae3f27ffffffff030000000000000000406a04534c500001410453454e4420da400de527913c3bac117ef8dcc01c05439e9ebea95fe4cd339757ddf3206c9808000000000000000008000000000000000180380100000000001976a914fc7250a211deddc70ee5a2738de5f07817351cef88ac22020000000000001976a914531260aa2a199e228c537dfa42c82bea2c7c1f4d88ac00000000
-a 546 -s a9147d5915e36b8635a96aeba1698ce031f9be8e9d4687

Markdown

Use https://markdownlivepreview.com/ to make sure it looks good

Reviewers: bytesofman, #bitcoin_abc

Reviewed By: bytesofman, #bitcoin_abc

Differential Revision: https://reviews.bitcoinabc.org/D16087

Details

Provenance
tobias_ruckAuthored on Tue, Apr 30, 15:15
tobias_ruckPushed on Fri, May 3, 01:09
Reviewer
Restricted Project
Differential Revision
D16087: [ecash-agora] Add `AgoraOneshot`
Parents
rABCc2159fe23a34: [chronik-client] Make sure we have a listener attached when emitting the ready…
Branches
Unknown
Tags
Unknown