Skip to content
SLP validator with pre-broadcast validation and burn protection.
TypeScript Python Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode
examples
fuzzer
lib
test
.gitignore
README.md
index.ts
package-lock.json
package.json
tsconfig.json
tslint.json

README.md

slp-validate

Lightweight SLP validator with pre-broadcast validation and burn protection.

NPM

Installation

For node.js

$ npm install slp-validate

For browser

<script src='https://unpkg.com/slp-validate'></script>

Example Usage

The recommended method to use for validation is ValidatorType1.isValidSlpTxn(). This method can check transaction validity before it is broadcast to the network to prevent accidental burning.

The following examples are provided in the examples directory:

  • 1-validate-tx-rpc-burn-valid-stop.ts: Prevents accidental sending of a valid burn transaction
  • 2-validate-tx-rpc-burn-valid-allow.ts: Allows sending a valid burn transaction
  • 3-validate-txid-rpc.ts: Traditional SLP validate method by txid (offers no extra burn protection).
  • 4-validate-txid-bchd.ts: Similar to example 3, but uses BCHD's gRPC instead of JSON RPC.
  • 5-validate-txid-gs++.ts: Validate more quickly by downloading transactions in bulk from SLP graph search instead of downloading transactions individually via RPC.

Unit Tests

$ npm run test

The majority of tests are driven by test vectors located in the slp-unit-test-data repository.

Differential Testing

Run differential fuzzing with Electron Cash SLP edition by following the docs in ./fuzzer/README.md.

Code Coverage

$ npm run test

Once differential testing is setup, you can see the lines covered by the fuzzer testing for ./lib/slp.ts:

$ cd fuzzer
$ ./coverage.sh

Change Log

1.1.2

  • fixed missing index.d.ts file
  • added differential fuzzing tests
  • added code coverage

1.1.1

  • added testing framework for differential fuzzing
  • fix missing null check in parseSlpOutputScript

1.1.0

  • fixed bug in isValidSlpTxn (issue #4)
  • added JSDoc headers to some core methods in validation.ts
  • use explicit checking of txn type when parsing SLP message
  • fixed missing "unpkg" declaration in package.json
  • more ts linting
  • (breaking change) renamed MapCache to CacheMap
  • (breaking change) removed .ts files from npm pkg, include .d.ts.

1.0.1

  • fixed severe security vulnerability in parseSlpOutputScript
  • add ts linting to the project
  • add example for using gs++ as validation source

1.0.0

  • ported validator from slpjs 0.21.3
  • store cached transactions as buffer instead of a string
  • add max cache size parameters in ValidatorType1 constructor

Acknowledgements

Thanks to cryptophyl.com for sponsoring the initial effort required to create this library.

You can’t perform that action at this time.