Class: Zold::Invoice

Inherits:
Object
  • Object
show all
Includes:
ThreadBadge
Defined in:
lib/zold/commands/invoice.rb

Overview

Generate invoice

Instance Method Summary collapse

Constructor Details

#initialize(wallets:, remotes:, copies:, log: Loog::NULL) ⇒ Invoice



22
23
24
25
26
27
# File 'lib/zold/commands/invoice.rb', line 22

def initialize(wallets:, remotes:, copies:, log: Loog::NULL)
  @wallets = wallets
  @remotes = remotes
  @copies = copies
  @log = log
end

Instance Method Details

#run(args = []) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/zold/commands/invoice.rb', line 29

def run(args = [])
  opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
    o.banner = "Usage: zold invoice ID [options]
Where:
'ID' is the wallet ID of the money receiver
Available options:"
    o.integer '--length',
      'The length of the invoice prefix (default: 8)',
      default: 8
    o.bool '--tolerate-edges',
      'Don\'t fail if only "edge" (not "master" ones) nodes have the wallet',
      default: false
    o.integer '--tolerate-quorum',
      'The minimum number of nodes required for a successful fetch (default: 4)',
      default: 4
    o.string '--network',
      'The name of the network we work in',
      default: 'test'
    o.bool '--help', 'Print instructions'
  end
  mine = Args.new(opts, @log).take || return
  raise 'Receiver wallet ID is required' if mine[0].nil?
  invoice(Id.new(mine[0]), opts)
end