Cyphernode simplifies to a large extent the historically cumbersome process for an individual to run a full-node and thus participate in the Bitcoin value network. The aim of the SDK is to further help access by bridging the gap between the "systems software" technological stack and the "product space" where product developers can start easily building apps for the future.
This SDK aims to abstract complications and offer a clean and friendly way to access the value proposition these systems offer with a value add of a modular transport.
- You need to have Cyphernode running on an HTTP accessible PC
- You must have a valid Cyphernode admin api key to run the tests and you must pass the key to the SDK tests. The easiest way to do so is using environment variables. Make sure the following enviroment variables are set when using the sdk:
CYPHERNODE_API_KEY=
CYPHER_GATEWAY_URL=https://localhost:2009/v0/
const {btcClient} = require('cyphernode-js-sdk');
const client = btcClient();
const balance = client.getBalance();
console.log(`Your balance is ${balance} bitcoins`);
const {lnClient} = require('cyphernode-js-sdk');
const client = lnClient();
const makeInvoicePayload = {
msatoshi: 10,
label: "much-ease-invoice",
description: "This rocks",
expiry: 900,
callback_url: "http://url.to/call/when/invoice/paid"
};
const invoice = await createInvoice(makeInvoicePayload);
// Show qrCode(invoice)
Documentation of this SDK is WIP in the meantime client tests serve as 'how-to' examples. Futhermore the SDK is written in typescript which should help give a better understanding of parameters and return types for the functions being called.
This SDK ships with a default HTTP transport stack, IE it will forward all your requests to the cyphernode endpoint via 'regular' GET and POST http requests. The HTTP transport stack is automatically initilaized by default when a client is instantiated and uses the isomorphic package 'superagent' to send HTTP requests and is in fact the only depedency this sdk has. This is in the name of ease of use for both node and browser users.
You can easily drop that dependancy from the sdk by modifiying ./transports/cypherNodeHTTPTransport.ts
(or creating a new one in our transports repo !).
A big part of this SDK seeks to help integrate Bitcoin into other communication protocols via the notion of transport architecture. Please check the Cyphernode transport repo for more information on how to reach your Cyphernode via different communication protocols
/clients/
Contains the individual clients that can be instaniated to access each of Cyphernode's services, at this time these are:
- btcClient.js : All things bitcoin
- lncClient.js : All things lighting
- otsClient.js : (WIP) All this opentimestamp
Test files for each client are included that showcase the usage of functionality
- All tests need to have Cyphernode running on your PC
- You must have a valid Cyphernode admin api key to run the tests and you must pass the key to the SDK tests. The easiest way to do so is using environment variables. Simply create a
.env
file in the root directory of this repo and add the following enviroment variables:
CYPHERNODE_API_KEY=
CYPHER_GATEWAY_URL=https://localhost:2009/v0/
then run
yarn test:clients
- JSDoc this puppy
- Test coverage for all functions
- Fix OTS functions
- Add remaining LN functions
- Add link to MVP app