lib/zold/wallet.rb
def sub(amount, invoice, pvt, details = '-', time: Time.now)
      raise 'The amount has to be of type Amount' unless amount.is_a?(Amount)
      raise "The amount can't be negative: #{amount}" if amount.negative?
      raise 'The pvt has to be of type Key' unless pvt.is_a?(Key)
      prefix, target = invoice.split('@')
      tid = max + 1
      raise 'Too many transactions already, can\'t add more' if max > 0xffff
      txn = Txn.new(
        tid,
        time,
        amount * -1,
        prefix,
        Id.new(target),
        details
      )
      txn = txn.signed(pvt, id)
      raise "Invalid private key for the wallet #{id}" unless Signature.new(network).valid?(key, id, txn)
      add(txn)
      txn
    end
def sub(amount, invoice, pvt, details = '-', time: Time.now)
      raise 'The amount has to be of type Amount' unless amount.is_a?(Amount)
      raise "The amount can't be negative: #{amount}" if amount.negative?
      raise 'The pvt has to be of type Key' unless pvt.is_a?(Key)
      prefix, target = invoice.split('@')
      tid = max + 1
      raise 'Too many transactions already, can\'t add more' if max > 0xffff
      txn = Txn.new(
        tid,
        time,
        amount * -1,
        prefix,
        Id.new(target),
        details
      )
      txn = txn.signed(pvt, id)
      raise "Invalid private key for the wallet #{id}" unless Signature.new(network).valid?(key, id, txn)
      add(txn)
      txn
    end
def sub ( amount , invoice , pvt , details = '-' , time : Time . now ) raise 'The amount has to be of type Amount' unless amount . is_a? ( Amount ) raise "The amount can't be negative: #{amount}" if amount . negative? raise 'The pvt has to be of type Key' unless pvt . is_a? ( Key ) prefix , target = invoice . split ( '@' ) tid = max + 1 raise 'Too many transactions already, can\'t add more' if max > 0xffff txn = Txn . new ( tid , time , amount * - 1 , prefix , Id . new ( target ) , details ) txn = txn . signed ( pvt , id ) raise "Invalid private key for the wallet #{id}" unless Signature . new ( network ) . valid? ( key , id , txn ) add ( txn ) txn end
Add a payment transaction to the wallet.
Add a payment transaction to the wallet .