npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lnsdk

v1.1.3

Published

* @Author: tonyTang * @Date: 2019-03-19 15:13:51 * @Last Modified by: tonyTang * @Last Modified time: 2019-03-20 15:30:22

Downloads

4

Readme

  • @Author: tonyTang
  • @Date: 2019-03-19 15:13:51
  • @Last Modified by: tonyTang
  • @Last Modified time: 2019-03-20 15:30:22


SDK提供的方法接口

  • login登陆方法

  • send发送方法

  • receive接收方法


npm install
npm run build

安装

  • node环境

npm install lnsdk --save-dev
  • 浏览器环境

npm run build 后生成一个lnSDK.min.js文件,直接引用

<script src="./static/lnSDK.min.js"></script>

let lnSDK = lnsdk;
//登陆
lnSDK.login().then(data => {
    console.log(data);
}).catch(err => {
    console.log(err);
});
//发送
lnSDK.send().then(data => {
    console.log(data);
}).catch(err => {
    console.log(err);
});
//接收
lnSDK.receive().then(data => {
    console.log(data);
}).catch(err => {
    console.log(err);
});
  • 也可以require引入

const lnSDK = require("./static/lnSDK.min.js");

使用示例Example

import lnSDK from 'lnsdk';

//登陆方法
lnSDK.login().then(data => {
    console.log(data);
    /*
    data: {
        code: 0,
        message: 'ok',
        client_id: "xxx", //clinet_id
        blance: 1000, //账户余额     
    }
    */
}).catch(err => {
    console.log(err);
    /*
    err: {
        code: -1, //失败code码
        message: 'xxxxxxx' //失败信息
    }
    */
});

//发送方法
let obj = {
    invoice: 'lnbc500n1pwfrhycpp5muwvf82zh8s8ggksvxvnjn2z4d3lm6nzarxvsv6n7j6t24wa22jsdqgdpjxs6rxcqzysxqyz5vqmek8rprdsmf7fx93z0s6aekw0wrm8x29x595ytmmu44szhe55vzr42mksce3vm6g92asjmwcpc96pa08vqsumtg43xea2vclz5h2zeqqpnr8zp'
    //闪电节点生成的收款代码
};
lnSDK.send(obj).then(data => {
    console.log(data);
    /* 
    成功的返回
    data: {
       code: 0,
       amount: 1000, //发送金额,以聪为单位(1000Statoshi)
       message: '成功'
    }
    */
    /*
    取消的返回
    data: {
        code: 1,
        message: '取消发送'
    }
    */
}).catch(err => {
    console.log(err);
    /*
    失败的情况
    err: {
        code: -1, //失败code码
        message: 'xxxxxxx' //失败信息
    }
    */
});

//发送方法,创建一个hoo闪电节点收款代码
//该方法有两种情形可调用
//1. 当lapp方向虎符闪电网络用户转帐时,不需要传client_id就能生成收款代码。
//2. 当lapp方没有自己的闪网络节点时,当用户向lapp发送(send)时,lapp要生成一个收款代码,这时候需要传clinet_id。(前提,lapp方需要时虎符闪电网络的用户)
let receiveObj = {
    memo: 'xxxxxx', //备注
    amount: 1000, //金额,以聪为单位(1000Statoshi)
    client_id: "xxx", //clinet_id,非必传,如果是lapp方向虎符用户发送,则不需要传。
}
lnSDK.receive(receiveObj).then(data => {
    console.log(data);
    /* 
    成功的返回
    data: {
        code: 0,
        message: 'ok',
        invoice: "xxx",       //收款单内容,app生成二维码
        memo: "xxx",          //备注
        amount: "xxx",        //金额
        expiry: 600,          //在600秒内有效
    }
    */
   
}).catch(err => {
    console.log(err);
    /*
    失败的情况
    err: {
        code: -1, //失败code码
        message: 'xxxxxxx' //失败信息
    }
    */
});