To add new scripts, Lumos provides registerCustomLockScriptInfos. For each lock script, a LockScriptInfo object is mandatory.
Inside LockScriptInfo.lockScriptInfo
, the lock script must implement following interfaces:
- The
CellCollector
must be a constructor function or class and is used by Lumos to locate live cells for transaction inputs. For each address and registered lock script, Lumos will create an instance ofCellCollector
. The responsibility of filtering out cells that do not match the lock script lies with theCellCollector
; Lumos does not perform this check. The initialized object's mandatory interface isasync *collect()
, an async generator. - When a live cell is found by the
CellCollector
instance, Lumos invokes thesetupInputCell
method within the correspondingLockScriptInfo
. This method is responsible for adding the input to the transaction and including a matching output cell. This is necessary since Lumos searches for the available balance of an address in the outputs during transaction building. - The
prepareSigningEntries
method serves as a callback in lumos.commons.common.prepareSigningEntries. Its purpose is to add signing entries for each input that requires storing a signature in the witness. A singing entry has 3 fields:index
: the witness index where the signature is storedmessage
: this refers to the message waiting for signature.type
: the one available value iswitness_args_lock
. This value specifies that the witness is a serializedWitnessArgs
, and its lock field contains the signature of the lock script.
- Live Cells Collector: Script is responsible for live cells filtering via
CellCollector
- Dep Cell: Via
setupInputCell
- Pre-fill Witness: Required, via
setupInputCell
- Signing: Via
prepareSigningEntries
and an external helper to generate signatures from signing entries. - Extra Data
- Has access to input cells
- Cannot access dep headers
LockScriptInfo
cannot receive extra data from client.
LockScriptInfo
lacks documentations about the interfaces.Lumos
imposes many implict requirements on the implementation ofsetupInputCell
.- Setting up a script requires a significant amount of bootstrap code. Compared to the Java example, it took over 100 lines of code more.