lib/bundler/thankyou/cli.rb in bundler-thankyou-0.1.0 vs lib/bundler/thankyou/cli.rb in bundler-thankyou-0.1.1

- old
+ new

@@ -59,15 +59,21 @@ exit end shell.print_table(recipients.to_a, indent: 4, truncate: true) say + Bundler::Thankyou.lnd_client = lnd_client + if !lnd_connected? + say 'Please connect your LND. Please run:', Shell::Color::RED + say '> bundler-thankyou setup', Shell::Color::BLUE + exit + end + if options[:amount].nil? self.amount = ask('How many sats do you want do send in total?', Shell::Color::RED).to_i say end - Bundler::Thankyou.lnd_client = lnd_client say "Sending #{amount} sats split among #{recipients.count} recipients" say if amount / recipients.count < MINIMUM_AMOUNT say "A minimum of #{MINIMUM_AMOUNT * recipients.count} sats is required", Shell::Color::RED @@ -102,9 +108,16 @@ end end def lnd_client @lnd_client ||= Lnrpc::Client.new(lnd_config) + end + + def lnd_connected? + lnd_client.macaroon && !!lnd_client.lightning.get_info + rescue StandardError => e + say e.messgae if options[:verbose] + false end def amount @amount || options[:amount] end