From 80e3fae21d89a6500e6db03c1f481c5643437b05 Mon Sep 17 00:00:00 2001 From: Michael Bumann Date: Tue, 12 Feb 2019 07:06:58 +0100 Subject: [PATCH] Add examples --- README.md | 2 ++ examples.rb | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 examples.rb diff --git a/README.md b/README.md index 466e9e9..bfdaeb5 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,8 @@ lnd = Lnrpc::Client.new({credentials_path: '/path/to.cert.cls', macaroon_path: ' lnd.get_info ``` +Also have a look at [examples.rb](https://github.com/bumi/lnrpc/blob/master/examples.rb) + #### Initializing a new client The Lnrpc::Client constructor allows the following options: diff --git a/examples.rb b/examples.rb new file mode 100644 index 0000000..db51bc2 --- /dev/null +++ b/examples.rb @@ -0,0 +1,15 @@ +require "lnrpc" + +lnd = Lnrpc::Client.new() # use defaults for credentials, macaraoon and address + +get_info_res = lnd.get_info +puts get_info_res.alias + +puts lnd.wallet_balance.total_balance + +pay_request = "lntb50u1pw9mmndpp5nvnff958pxc9eqknwntyxapjw7l5grt5e2y70cmmnu0lljfa0sdqdpsgfkx7cmtwd68yetpd5s9xct5v4kxc6t5v5s8yatz0ysxwetdcqzysxqyz5vqjkhlyn40z76gyn7dx32p9j58dftve9xrlvnqqazht7w2fdauukhyhr9y4k3ngjn8s6srglj8swk7tm70ng54wdkq47ahytpwffvaeusp500csz" +lnd.pay(pay_request) # or: +lnd.send_payment_sync(payment_request: pay_request) + +invoice_res = lnd.add_invoice(value: 1000, memo: 'I :heart: ruby') +puts invoice_res.payment_request