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

blockstream-js-client

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

blockstream-js-client

The implementation of the Blockstream Satellite API

  • 1.0.2
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
48
decreased by-5.88%
Maintainers
1
Weekly downloads
 
Created
Source

Blockstream JS Client 🙂

Overview

Find the Documentation for the Blockstream Satellite API here

Install

npm install blockstream-js-client

Usage

Based on the node environment, this package will shuttle between the main network or the test network.

const B = require('blockstream-js-client');

// Create an Order on the main or test blockstream network
const { auth_token, uuid } = await B.createOrder({
  bid: '10000', // Amount in millisatoshi
  message: `Paschal's bid for a Tesla`,
});

// Edit Bid
B.increaseBid({
  bid_increase: '4000',
  auth_token,
  uuid,
})
  .then((res) => console.log({ res }))
  .catch((error) => console.error(error));

// Monitor the status of the order / Get order
B.getOrder({
  auth_token,
  uuid,
})
  .then((res) => console.log({ res }))
  .catch((error) => console.error(error));

// Delete Order
B.deleteOrder({
  auth_token,
  uuid,
})
  .then((res) => console.log({ res }))
  .catch((error) => console.error(error));

// Get pending, sent and queued orders
B.getOrders({
  state: 'pending',
})
  .then((res) => console.log({ res }))
  .catch((error) => console.error(error));

// Get information about the c-lightning node API
B.getInfo()
  .then((res) => console.log({ res }))
  .catch((error) => console.error(error));

// Subscribe to channels (The only available channel now is the "transmissions" channel)
B.subscribeToChannels(['transmissions'])
  .then((res) => console.log({ res }))
  .catch((error) => console.error(error));

API

This uses some TS definitions.
| means OR
? means OPTIONAL

  • createOrder: Create an Order on the main or test blockstream network

    Usage: createOrder({bid : string, file? : string, message?: string})

    bid: Amount in millisatoshi. Required.
    file: Link to an attachment. Optional.
    message: Message to describe the order. Optional.

    Returns:

     // Success
     {
      error?: false;
      auth_token: string;
      uuid: string;
      lightning_invoice_id: string;
      description: string;
      status: string;
      msatoshi: string | number;
      payreq: string;
      expires_at: number;
      created_at: number;
      metadata: object;
    }
    
    // Error
    {
      error?: true;
      message: string;
    }
    
  • increaseBid: Increase the bid for a particular order

    Usage: increaseBid({auth_token : string, uuid : string, bid_increase : string })

    auth_token: Authentication token. Required.
    uuid: Universally unique identifier. Required.
    bid_increase: Amount to increase bid by, Millisatoshi. Required.

    Returns:

    // Success
     {
      error?: false;
      auth_token: string;
      uuid: string;
      lightning_invoice_id: string;
      description: string;
      status: string;
      msatoshi: string | number;
      payreq: string;
      expires_at: number;
      created_at: number;
      metadata: object;
    }
    
    // Error
    {
      error?: true;
      message: string;
    }
    
  • getOrder: Fetch the details of a particular order

    Usage: getOrder({uuid: string, auth_token: string})

    uuid: Required.
    auth_token: Required.

    Returns:

      //Success
      {
          error?: false;
          bid: number | string;
          message_digest: string;
          status: string;
          uuid: string;
          created_at: Date;
          started_transmission_at: Date;
          ended_transmission_at: Date;
          tx_seq_num: string;
          unpaid_bid: number | string;
      }
    
    // Error
      {
          error?: true;
          message: string;
      }
    
  • getOrders: Get orders that have either been sent, pending or queued.

    Usage: getOrders({state: string, limit?: number, before?: string})

    state: 'pending' | 'sent' | 'queued'. Required.
    limit: Limit length of response. Optional. Defaults to 20.
    before: The date to query with. Optional.

    Returns:

 //Success
   {
      error?: false,
      data: [{
        error?: false;
        bid: number | string;
        message_digest: string;
        status: string;
        uuid: string;
        created_at: Date;
        started_transmission_at: Date;
        ended_transmission_at: Date;
        tx_seq_num: string;
        unpaid_bid: number | string;
      }],
    };

  // Error
    {
        error?: true;
        message: string;
    }
  • deleteOrder: Delete a Particular Order

    Usage: deleteOrder({uuid: string, auth_token: string})

    uuid: Required.
    auth_token: Required.

    Returns:

 //Success
    {
      error?: false,
      message: string,
    }

  // Error
    {
        error?: true;
        message: string;
    }
  • getInfo: Get information about the c-lightning node.

    Usage: getInfo()

    Returns:

 //Success
   {
        error: false;
        id: string;
        alias: string;
        color: string;
        number_of_peers: string | number;
        number_of_active_channels: string | number;
        number_of_inactive_channels: string | number;
        number_of_pending_channels: string | number;
        binding: Array<object>;
        msatoshi_fees_collected: string | number;
        fees_collected_msat: string;
        lightning_directory: string;
        address: Array<object>;
        version: string;
        blockheight: string | number;
        network: string;
    }

  // Error
    {
        error?: true;
        message: string;
    }
  • subscribeToChannels: Subscribe to server-sent event channels. The only channel available now, is the transmissions channel.
    Usage: subscribeToChannels(channels: Array)

    channels: Array of channels. Required.

    Returns:

 //Success
   {
      error?: false,
      message: string,
    }

  // Error
    {
        error?: true;
        message: string;
    }

Keywords

FAQs

Package last updated on 05 Jul 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