lib/zold/commands/pay.rb in zold-0.20.0 vs lib/zold/commands/pay.rb in zold-0.20.1

- old
+ new

@@ -35,13 +35,14 @@ module Zold # Money sending command class Pay prepend ThreadBadge - def initialize(wallets:, remotes:, log: Log::NULL) + def initialize(wallets:, remotes:, copies:, log: Log::NULL) @wallets = wallets @remotes = remotes + @copies = copies @log = log end def run(args = []) opts = Slop.parse(args, help: true, suppress_errors: true) do |o| @@ -57,10 +58,16 @@ require: true, default: File.expand_path('~/.ssh/id_rsa') o.bool '--force', 'Ignore all validations', default: false + 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.bool '--dont-pay-taxes', 'Don\'t pay taxes even if the wallet is in debt', default: false o.bool '--skip-propagate', 'Don\'t propagate the paying wallet after successful pay', @@ -72,12 +79,13 @@ id = Id.new(mine[0]) raise 'Recepient\'s invoice or wallet ID is required as the second argument' if mine[1].nil? invoice = mine[1] unless invoice.include?('@') require_relative 'invoice' - invoice = Invoice.new( - wallets: @wallets, remotes: @remotes, copies: @copies, log: @log - ).run(['invoice', invoice]) + invoice = Invoice.new(wallets: @wallets, remotes: @remotes, copies: @copies, log: @log).run( + ['invoice', invoice, "--tolerate-quorum=#{opts['tolerate-quorum']}"] + + (opts['tolerate-edges'] ? ['--tolerate-edges'] : []) + ) end raise 'Amount is required (in ZLD) as the third argument' if mine[2].nil? amount = Amount.new(zld: mine[2].to_f) details = mine[3] || '-' taxes(id, opts)