GithubHelp home page GithubHelp logo

hawkmauk / txref-conversion-js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from weboftrustinfo/txref-conversion-js

0.0 0.0 0.0 1.08 MB

Javascript library for converting txids to txrefs and back

License: MIT License

JavaScript 100.00%

txref-conversion-js's Introduction

TXRef conversion javascript library

About

Javascript library for Bech32 Encoded TX References, ported from Jonas Schnelli's reference implementation for the Rebooting Web Of Trust's BTCR Hackathon. It uses Peter Wuille's Bech32 library for Bech32 encoding and decoding.

For more details, see the Bech32 Encoded Transaction Position References BIP.

This implementation works as follows:

  • Encoding:

    • Given a txid and chain (testnet/mainnet), fetch the block height and position from a blockchain explorer
    • Convert to a short id as shown in btc_txref_encode
  • Decoding:

    • Decodes the bech32-encoded txref
    • Extracts the block height and position as shown in btc_txref_decode
    • Find the txid corresponding to the blockheight and position from a blockchain explorer

This library is for prototype use only. Some future improvements would include:

  • Checking confirmation count from the API results; warn if less than 6 (or some other threshold).
  • Compare results from multiple blockchain explorer APIs
  • Flexible accessor if a local bitcoin node is available.
  • Robust error checking

You can use this as a node package or in a browser. The browserified script is available as txrefConverter-browserified.js.

Preview

You can experiment with this library in the BTCR TX Playground

Developer information

JSDOC is used to generate developer resources that can be found here

Install

git clone https://github.com/WebOfTrustInfo/tx-conversion-js
cd tx-conversion-js
npm install

Using in a browser

\\TODO

See the BTCR playground code repository btcr-tx-playground for working code samples.

Running tests

npm run test

Generate JSDOC

Code is commented to generate JSDOC that can be found in the docs directory

npm run doc

txref-conversion-js's People

Contributors

danpape avatar hawkmauk avatar kimdhamilton avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.