Skip to content

chainpoint/lightning-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lightning-go

License

This golang library is used by Chainpoint Core to connect with a Lightning Network Daemon over grpc. By default Lightning, Wallet, WalletUnlocker, and Invoice clients are available. A number of convenience methods for working with Lightning Service Authentication Tokens and interacting with the Bitcoin blockchain are also provided. By default this library is intended to work with Tierion Inc's fork of lnd, but other than exposing a block retrieval method, there is little difference from the original repository.

Install

This package requires Go modules.

go get github.com/chainpoint/lightning-go

Usage

A basic example of declaring the library is provided below.

package main

import (
    lightning "github.com/chainpoint/lightning-go"
    "encoding/json"
    "fmt"
    "time"
)

func main() {
    lndClient := lightning.LightningClient{
                        TlsPath:             "/home/ubuntu/.lnd/tls.cert",
                        MacPath:             "/home/ubuntu/.lnd/data/chain/bitcoin/mainnet/admin.macaroon",
                        ServerHostPort:      "127.0.0.1:10009",
                        LndLogLevel:         "error",
                        MinConfs:            3,
                        Testnet:             "mainnet",
                        WalletAddress:       "your_wallet_address",
                        WalletPass:          "your_wallet_password",
                        WalletSeed:          "your_wallet_seed",
                        HashPrice:           int64(2), //price to charge for issuing LSAT
                        SessionSecret:       "a mutual secret between lsat servers and clients",
                  }
     lndClient.WaitForConnection(5 * time.Minute)  //Wait until lnd is ready
     lndClient.Unlocker()                          //Unlock wallet 
     info, err := lndClient.GetInfo()              //Make a call to get lnd node info
     if err == nil {
         infoJson, _ := json.Marshal(info)
         fmt.Println(string(infoJson)) 
     }
}

Additionally an example of a server-side LSAT flow, RespondLSAT, is provided in lsat.go

About

Lightning (lnd) grpc client in golang

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages