ltx_connect

0.0.5 • Public • Published

LibertyX Connect: Node JS Client

LibertyX Connect is a client library that lets your bitcoin service effortlessly accept and request cash payments from LibertyX.

Authors Apoorva Bhagwat, Raunak Agnihotri, Yush Gupta

Contact yush@libertyx.com

How it works

You simply import the ltx_connect client library, which opens, and manages a bidirectional websocket connection to the LibertyX connect server.

var ltx = require('ltx_connect')

Initialization

var options = {'sandbox': true, 'rpc': true }
function on_connect() {
  console.log('Websocket connection established')
}
ltx.connect('<YOUR SERVICE NAME>', options, on_connect)

Request handlers

You then implement request handling functions specific to your bitcoin service

ltx.on('action', function (data, respond) {
    if (!data.order_id) {
        throw Error('You need to supply an order id')
    }

    respond({'some': 'response'})
})

Sending requests to LibertyX

ltx.send('action', {'some': 'arguments'}, function (rsp) {
    console.log('Response',rsp)
})

Standard handlers:

order_create        Creates a new order, along with the order id
order_update        Update information on the existing order (optional)
order_get           Returns the order information
btc_send            Invoked whenever LibertyX sends bitcoin (optional)

Getting started

Installation

# Download the sample client implementation
git clone https://bitbucket.org/snippets/libertyx/pkdA7 ltx_connection
cd ltx_connection

# Install the library
npm init --yes
npm install ltx_connect --save

# In terminal 1
node test_client.js

# In terminal 2
node test_rpc.js

Customize test_client.js with the code for your bitcoin service

Package Sidebar

Install

npm i ltx_connect

Weekly Downloads

0

Version

0.0.5

License

BSD-2-Clause

Last publish

Collaborators

  • libertyx