[ecash-lib] Add agora advertisements (ads) of offers for AgoraOneshot
Summary:
Currently, ecash-agora can be used to broadcast offers on the network, but it's impossible to find them purely by looking at the blockchain, as the Agora covenant is in a P2SH, which is irreversible.
Ideally, we'd put the offer data into an OP_RETURN, however, for SLP, the OP_RETURN is fully occupied with SLP data, so we have to put it somewhere else. One proven method is to put it into the scriptSig, which we do in this diff:
A scriptSig advertising a oneshot offer will look like this:
"AGR0" "ONESHOT" <sellerSig> <redeemScript with the terms>
- AgoraOneshot gets a method adScript, which builds a script that, when spent using AgoraOneshotAdSignatory, will advertise the terms of the offer on the chain.
- AgoraOneshot.fromRedeemScript will reconstruct the terms of an advertisement based on the redeemScript.
- parseAgoraTx will parse a Tx coming from Chronik as Agora tx, returning ParsedAd, parsing the terms, but also verifying the output actually matches the terms, to avoid trying to spend an offer that actually doesn't have the advertised terms in the P2SH.
ParsedAd's definition is intended to be easy to extend with other kinds of terms.
Depends on D16088
Test Plan: BUILD_DIR=../../build npm run integration-tests
Reviewers: bytesofman, #bitcoin_abc, Fabien
Reviewed By: bytesofman, #bitcoin_abc, Fabien
Subscribers: Fabien
Differential Revision: https://reviews.bitcoinabc.org/D16111