lib/zold/commands/pay.rb in zold-0.29.23 vs lib/zold/commands/pay.rb in zold-0.29.24
- old
+ new
@@ -43,10 +43,12 @@
@remotes = remotes
@copies = copies
@log = log
end
+ # Sends a payment and returns the transaction just created in the
+ # paying wallet, an instance of Zold::Txn
def run(args = [])
opts = Slop.parse(args, help: true, suppress_errors: true) do |o|
o.banner = "Usage: zold pay wallet target amount [details] [options]
Where:
'wallet' is the sender's wallet ID
@@ -99,15 +101,16 @@
end
raise 'Amount is required (in ZLD) as the third argument' if mine[2].nil?
amount = amount(mine[2].strip)
details = mine[3] || '-'
taxes(id, opts)
- @wallets.acq(id, exclusive: true) do |from|
+ txn = @wallets.acq(id, exclusive: true) do |from|
pay(from, invoice, amount, details, opts)
end
return if opts['skip-propagate']
require_relative 'propagate'
Propagate.new(wallets: @wallets, log: @log).run(['propagate', id.to_s])
+ txn
end
private
def amount(txt)