Interface LockScriptInfo

LockScriptInfo describes how to integrate a lock script in transaction building.

Custom lock scripts must register their LockScriptInfo before using transfer, injectCapacity, payFee, payFeeByFeeRate via registerCustomLockScriptInfos.

See an example in custom_lock_script_info.ts.

Hierarchy

  • LockScriptInfo

Properties

codeHash: string
hashType: HashType
lockScriptInfo: {
    CellCollector: commons.CellCollectorConstructor;
    setupOutputCell?: ((txSkeleton, outputCell, options) => Promise<helpers.TransactionSkeletonType>);
    prepareSigningEntries(txSkeleton, options) => helpers.TransactionSkeletonType;
    setupInputCell(txSkeleton, inputCell, fromInfo?, options?) => Promise<helpers.TransactionSkeletonType>;
}

Type declaration

  • CellCollector: commons.CellCollectorConstructor

    Collects input cell candidates for the lock script.

    It's a constructor that initializes objects implementing function collect() to provide input cells. Attention that transaction builders will not match fromInfo and lock script. It's the responsibility of CellCollector to filter based on fromInfo. For example, when fromInfo does not match, the function collect() should not return any cell.

  • Optional setupOutputCell?: ((txSkeleton, outputCell, options) => Promise<helpers.TransactionSkeletonType>)
  • prepareSigningEntries:function
  • setupInputCell:function
    • Called when a candidate input cell is found.

      What this function should do:

      1. Frist double-check the cell and decide whether continue the following steps or skip.
      2. Add the cell as an input in the txSkeleton and an output cell with the same fields since functions like transfer, injectCapacity, payFee, and payFeeByFeeRate collects account balance in outputs.
      3. Add cellDeps
      4. Prefill witnesses to ensure the transaction size will not increase after signing.

      Parameters

      • txSkeleton: helpers.TransactionSkeletonType

        transaction skeleton built so far

      • inputCell: Cell

        the new input cell candidate

      • Optional fromInfo: commons.FromInfo

        which account the inputCell belongs to

      • Optional options: {
            config?: config.Config;
            defaultWitness?: string;
            since?: string;
        }
        • Optional config?: config.Config
        • Optional defaultWitness?: string
        • Optional since?: string

      Returns Promise<helpers.TransactionSkeletonType>

      the updated transaction skeleton

Generated using TypeDoc