Lightweight SLP validator with pre-broadcast validation and burn protection.
$ npm install slp-validate
<script src='https://unpkg.com/slp-validate'></script>
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 transaction2-validate-tx-rpc-burn-valid-allow.ts
: Allows sending a valid burn transaction3-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.
$ npm run test
The majority of tests are driven by test vectors located in the slp-unit-test-data repository.
Run differential fuzzing with Electron Cash SLP edition by following the docs in ./fuzzer/README.md.
$ 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
- Fixed edge case for NFT child validation using updated set of SLP unit tests
- Removed extraneous transaction length check
- Fixed false positive case for MINT validation
- Added new methods "addValidTxnFromStore" and "addValidTxidFromStore" for pre-loading validator cache
- "addValidationFromStore" will be deprecated in the next version 1.3.0
- Updated Graph Search (via gs++) snippet in the examples directory
- Update tsconfig & unit test config
- Linting nits
- (breaking change) Created Crypto.HashTxid() method and removed reverse from Crypto.Hash256(), removed Crypto.hash256()
- move @types/big.js to dep
- fixed missing index.d.ts file
- added differential fuzzing tests
- added code coverage
- added testing framework for differential fuzzing
- fix missing null check in parseSlpOutputScript
- 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.
- fixed severe security vulnerability in parseSlpOutputScript
- add ts linting to the project
- add example for using gs++ as validation source
- ported validator from slpjs 0.21.3
- store cached transactions as buffer instead of a string
- add max cache size parameters in ValidatorType1 constructor
Thanks to cryptophyl.com for sponsoring the initial effort required to create this library.