lib/zold/patch.rb in zold-0.13.41 vs lib/zold/patch.rb in zold-0.13.42

- old
+ new

@@ -72,11 +72,13 @@ dup = @txns.find { |t| t.id == txn.id && t.amount.negative? } if dup @log.error("An attempt to overwrite #{dup.to_text} with this: #{txn.to_text}") next end - if @txns.map(&:amount).map(&:to_i).inject(&:+).to_i < txn.amount.to_i * -1 && !wallet.root? - @log.error("Transaction ##{txn.id} attempts to make the balance of #{wallet.id} negative: #{txn.to_text}") + balance = @txns.map(&:amount).map(&:to_i).inject(&:+).to_i + if balance < txn.amount.to_i * -1 && !wallet.root? + @log.error("Transaction ##{txn.id} attempts to make the balance of \ +#{wallet.id}/#{Amount.new(coins: balance).to_zld}/#{@txns.size} negative: #{txn.to_text}") next end unless Signature.new.valid?(@key, wallet.id, txn) @log.error("Invalid RSA signature at transaction ##{txn.id} of #{wallet.id}: #{txn.to_text}") next