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: Log::NULL) ⇒ Invoice

Returns a new instance of Invoice.



39
40
41
42
43
44
# File 'lib/zold/commands/invoice.rb', line 39

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

Instance Method Details

#run(args = []) ⇒ Object



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/zold/commands/invoice.rb', line 46

def run(args = [])
  @log.debug("Invoice.run(#{args.join(' ')})")
  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