npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

jeton-lib

v2.1.0

Published

Extension of bitcore-lib-cash for advanced Bitcoin Cash transaction types

Readme

Jeton Lib

Extension of bitcore-lib-cash for advanced Bitcoin Cash transaction types

Purpose

Bitcoin Cash has script functionality, such as OP_CHECKDATASIG which is unique among Bitcoin forks. This functionality allows Bitcoin Cash users to particpate in on-chain, non-custodial escrow transactions (and more). Jeton Lib extends the popular bitcore-lib-cash library to allow for easy creation of transactions which leverage the powerful capabilities of Bitcoin Cash.

Get Started

npm install jeton-lib

Adding Jeton Lib to your app's package.json:

"dependencies": {
    "jeton-lib": "^2.1.0",
    ...
}

Examples

Complete examples are located in the /examples directory.

Examples include:

  • Multi-party escrow with an arbitrary message signed by an oracle
  • Multi-party escrow with a price message signed by an oracle
  • Covenant escrow - multisig, anyone-can-spend, and proportional

Include jeton-lib wherever you use bitcore-lib-cash

const jeton = require('jeton-lib')
const PrivateKey = jeton.PrivateKey
const Signature = jeton.Signature
const OutputScript = jeton.escrow.OutputScript
const Transaction = jeton.Transaction

Generate an escrow scriptPubKey

// Create keypairs for 3 players and a referee
var priv1 = new PrivateKey("L1wChPjacPamAFVbUsZZi5cEd3kMysZSgfDGprGEj91wTP6sh7KH")
var pub1 = priv1.toPublicKey()
var priv2 = new PrivateKey("KzyhHmmxwFbv2Mo8bQsJQwXhrCgAtjsCmuqBBmGZrcjfTn1Xvzw1")
var pub2 = priv2.toPublicKey()
var priv3 = new PrivateKey("KzwmMwHjbmRRdtwVUowKpYmpnJmMaVyGTwYLmh2qmiWcqgd7W9fG")
var pub3 = priv3.toPublicKey()

var refPriv = new PrivateKey('L5FDo3MEb2QNs2aQJ5DVGSDE5eBzVsgZny15Ri649RjysWAeLkTs')
var refpk = refPriv.toPublicKey();

// Create the output script
// parties[].pubKey can be an instance of PublicKey or Address
var outputScriptData = {
    refereePubKey: refpk,
    parties: [
        {message: 'player1wins', pubKey: pub1.toAddress()},
        {message: 'player2wins', pubKey: pub2.toAddress()},
        {message: 'player3wins', pubKey: pub3.toAddress()}
    ]
}

outScript = new OutputScript(outputScriptData)
assert(outScript.toScript().toASM() === 'OP_DUP 706c617965723177696e73 OP_EQUAL OP_IF OP_DROP 706c617965723177696e73 02d180cd5d509cf23fd2139ea53634bac12d29d0a71d22ad97a59a9379faa3250a OP_CHECKDATASIGVERIFY OP_DUP OP_HASH160 44a45625a1fda976376e7d59d27fc621f9c9d382 OP_ELSE OP_DUP 706c617965723277696e73 OP_EQUAL OP_IF OP_DROP 706c617965723277696e73 02d180cd5d509cf23fd2139ea53634bac12d29d0a71d22ad97a59a9379faa3250a OP_CHECKDATASIGVERIFY OP_DUP OP_HASH160 9383fa6588a176c2592cb2f4008d779293246adb OP_ELSE OP_DUP 706c617965723377696e73 OP_EQUAL OP_IF OP_DROP 706c617965723377696e73 02d180cd5d509cf23fd2139ea53634bac12d29d0a71d22ad97a59a9379faa3250a OP_CHECKDATASIGVERIFY OP_DUP OP_HASH160 b011100d12d0537232692b3c113be5a8f5053955 OP_ENDIF OP_ENDIF OP_ENDIF OP_EQUALVERIFY OP_CHECKSIG')

Create a transaction with a P2SH output from escrow script

var utxo = new Transaction.UnspentOutput({ 
    txid:
    'ee874221a431cf09d3373c4b9ffbb1e8fe80526d4304695e2f97541fc084c8f4',
    vout: 1,
    satoshis: 10200,
    scriptPubKey: '76a914b011100d12d0537232692b3c113be5a8f505395588ac' 
})

var fundEscrowTx = new Transaction()
        .from(utxo)          // Feed information about what unspent outputs one can use
        .toP2SH(outScript, 10000)
        .sign([priv2])     // Signs all the inputs it can

Spend escrow UTXO

var escrowUtxo = Transaction.utxoFromTxOutput(fundEscrowTx, 0)

// Make Transaction from escrow UTXO
var sighash = (Signature.SIGHASH_ALL | Signature.SIGHASH_FORKID)

var spendEscrowTx = new Transaction()
.from(escrowUtxo)
.to(priv1.toAddress(), 9000)

// Sign message with referee private key for player 1 wins
var refereeSig = Signature.signCDS(outputScriptData.parties[0].message, refPriv)

// Sign CDS input at index 0 as player 1
spendEscrowTx.signEscrow(0, priv1, outputScriptData.parties[0].message, refereeSig, outScript.toScript(), sighash)

License

Code released under the MIT license.