UNPKG

ecash-agora

Version:

Library for interacting with the eCash Agora protocol

34 lines 1.88 kB
import { Ecc, Script, TxOutput, UnsignedTxInput } from 'ecash-lib'; /** * Agora offer that has to be accepted in "one shot", i.e. all or nothing. * This is useful for offers that offer exactly 1 token, especially NFTs. * * The covenant is reasonably simple, see * https://read.cash/@pein/bch-covenants-with-spedn-4a980ed3 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 `1000....00000`, which can be created with * `OP_1 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). **/ export declare class AgoraOneshot { static COVENANT_VARIANT: string; enforcedOutputs: TxOutput[]; cancelPk: Uint8Array; constructor({ enforcedOutputs, cancelPk, }: { enforcedOutputs: TxOutput[]; cancelPk: Uint8Array; }); /** Build the Script enforcing the Agora offer covenant. */ script(): Script; static fromRedeemScript(redeemScript: Script, opreturnScript: Script): AgoraOneshot; adScript(): Script; askedSats(): bigint; } export declare const AgoraOneshotSignatory: (covenantSk: Uint8Array, covenantPk: Uint8Array, numEnforcedOutputs: number) => (ecc: Ecc, input: UnsignedTxInput) => Script; export declare const AgoraOneshotCancelSignatory: (cancelSk: Uint8Array) => (ecc: Ecc, input: UnsignedTxInput) => Script; export declare const AgoraOneshotAdSignatory: (cancelSk: Uint8Array) => (ecc: Ecc, input: UnsignedTxInput) => Script; //# sourceMappingURL=oneshot.d.ts.map