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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@xourse/tpay-transaction-helper

v3.3.6

Published

Client-side Bitcoin JavaScript library

Downloads

13

Readme

TokenpayJS

js-standard-style

A javascript TokenPay library for node.js and browsers.

Released under the terms of the MIT LICENSE.

Installation

npm i @xourse/tpay-transaction-helper

Typically we support the Node Maintenance LTS version. If in doubt, see the .travis.yml for what versions are used by our continuous integration tests.

WARNING: We presently don't provide any tooling to verify that the release on npm matches GitHub. As such, you should verify anything downloaded by npm against your own verified copy.

Usage

TokenPay Transaction Example

import transactionHelper from '@xourse/tpay-transaction-helper';
import bitcore, { PrivateKey, PublicKey } from 'bitcore-lib';

const sendNetwork = {
    messagePrefix: '\x19TokenPay Signed Message:\n',
    bip32: {
      public: 0x0488b21e,
      private: 0x0488ade4,
    },
    pubKeyHash: 0x41,
    scriptHash: 0x7e,
    wif: 0xb3,
  };

  // array of privatekeys for all address involved in the utxos
  // in this case privatekey is an instance of bitcore.PrivateKey
  const privateKeys = [];

  // utxos array, single utxo for example:
  //{
  //  txid: "952131742ee54457f7038dc38f0fc826ba89af93cccbb0e315290f4e2592be16",
  //  vout: 1,
  //  amount: 0.0028,
  //  address: "sv6tQJHUhLiQkTRLNNvvjPksifupJ3AArJ"
  //}
  const utxos = [];

  const tx = new transactionHelper.TransactionBuilder(sendNetwork);
  tx.setVersion(1);
  // add main output, multiple if required
  tx.addOutput(<address string>, <satoshiAmount number>);
  // add inputs, as many as necesary
  tx.addInput(<utxo.txid string>, <utxo.vout number>);
  // choose fee and calculate change amount
  const fee = 0.0005 // for example
  const changeAmount = <totalInputsAmount> - <totalAmountToSend> - fee
  if(changeAmount > 0){
    const changeAddress = 'string';
    tx.addOutput(<changeAddress string>, <satoshiAmount number>);
  }
  // sign each input with the private key from the address which owns the utxo
  for (let j = 0; j < utxos.length; j++) {
    for (const privateKey of privateKeys) {
      if (utxos[j].address === privateKey.toAddress().toString()) {
        const tempPair = transactionHelper.ECPair.fromWIF(privateKey.toWIF(), sendNetwork);
        tx.sign(j, tempPair);
      }
    }
  }

  // build the transaction
  const hextosend = tx.build().toHex();

  // broadcast the hextosend

Complementing Libraries

  • BIP21 - A BIP21 compatible URL encoding library
  • BIP38 - Passphrase-protected private keys
  • BIP39 - Mnemonic generation for deterministic keys
  • BIP32-Utils - A set of utilities for working with BIP32
  • BIP66 - Strict DER signature decoding
  • BIP68 - Relative lock-time encoding library
  • BIP69 - Lexicographical Indexing of Transaction Inputs and Outputs
  • Base58 - Base58 encoding/decoding
  • Base58 Check - Base58 check encoding/decoding
  • Bech32 - A BIP173 compliant Bech32 encoding library
  • coinselect - A fee-optimizing, transaction input selection module for bitcoinjs-lib.
  • merkle-lib - A performance conscious library for merkle root and tree calculations.
  • minimaldata - A module to check bitcoin policy: SCRIPT_VERIFY_MINIMALDATA

Alternatives

LICENSE MIT