Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

grpc-bchrpc-browser

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grpc-bchrpc-browser

BCHD gRPC client for browsers

  • 0.16.5-v2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

A bchd rpc client for browsers using grpc/grpc-web

This package provides a simple gRPC client for connecting web applications to a bchd full node.

A mobile friendly version of this project is formatted from markdown by github pages.

Getting Started

For a quick example usage subscribing transactions see the console here, or an experimental example using this module in a web worker.

Detailed RPC Documentation for the rpc protocol is a work in progress.

Client Documentation detailing methods and utility functions.

Mocha browser tests should provide some working examples.

This is slightly more than a stock client generated from protocol buffers. The following utilities have been added:

  • Simple utilities to transform hex/base64/Uint8Arrays without nodejs Buffer
  • A function to transform a number to a little-endian array
  • Functions to validate a merkle proof from bchd
  • A class to read and match compact filters for outpoints and public keys

For Bitcoin Cash and bchd specifically, functions are currently here to validate a transaction and block, as well as other utilities to handle different data types used or sent by bchd.

Motivation

This project uses Google's grpc/grpc-web library to generate a client, rather than the older and more widely used @improbable-eng/grpc-web.

The client is built from the pb files in advance rather than on-the-fly, a functionality which may be employed with the @improbable library.

The motivation is toward lower maintenance, long-term stability and support by using the google library, not that this thinking played out well with the framework formerly known as angular.

One notable limitation of the official grpc/grpc-web library is a lack of FETCH support.

See also

Alternative implementations of this project are built using the improbable-eng library here:

Scripts

Note: this project was created in node v12.2.0 (LTS) and used protoc version 3.11.4; and is open to using features from es2017 although initially targeted at es6.

Build

To build:

npm run build        # transpile typescript, browserify and minify use
npm run build:docs   # build documentation for the client class

Running Tests

Tests can be run either from console or in a browser. The typescript is loaded via ts-node, in that context.

npm run test          # run tests in node
npm run test:browser  # run tests in a browser

Updating the Spec

If for some reason you need to update the gcash proto files yourself to add some future functionality use:

npm run pb-clean     # remove old definitions
npm run pb-update    # download bchrpc.proto from gcash/bchd/master
npm run pb-build     # create client library
npm run pb-doc       # generate documentation

Important: an installed version of protoc
is required to run pb-build.

IN ADDITION you must have protoc-gen-grpc-web, see grpc-web

Using bchrpc in a Postman-like webgui

To facilitate debugging and development of the client, it may be useful make calls using a webui. The following npm scripts are provided, assuming you have golang installed.

npm run pb-grpcui-install     # install grpcui
npm run pb-grpcui             # run a local webui against a bchd node

BCHD Full Nodes w/ gRPC

Mainnet:

Testnet:

Keywords

FAQs

Package last updated on 20 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc