lib/zold/patch.rb in zold-0.16.21 vs lib/zold/patch.rb in zold-0.16.22
- old
+ new
@@ -69,18 +69,14 @@
@log.error("Wallet ID mismatch, ours is #{@id}, theirs is #{wallet.id}")
return
end
wallet.txns.each do |txn|
next if @txns.find { |t| t == txn }
- if @txns.find { |t| t.id == txn.id && t.bnf == txn.bnf }
- @log.error("A transaction with the same ID #{t.id} and BNF #{t.bnf} already exists")
- next
- end
if txn.amount.negative?
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}")
+ @log.error("An attempt to overwrite \"#{dup.to_text}\" with \"#{txn.to_text}\" from #{wallet.mnemo}")
next
end
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 \
@@ -90,9 +86,14 @@
unless Signature.new.valid?(@key, wallet.id, txn)
@log.error("Invalid RSA signature at transaction ##{txn.id} of #{wallet.id}: #{txn.to_text}")
next
end
else
+ dup = @txns.find { |t| t.id == txn.id && t.bnf == txn.bnf && t.amount.positive? }
+ if dup
+ @log.error("Overwriting \"#{dup.to_text}\" with \"#{txn.to_text}\" from #{wallet.mnemo} (same ID/BNF)")
+ next
+ end
if !txn.sign.nil? && !txn.sign.empty?
@log.error("RSA signature is redundant at ##{txn.id} of #{wallet.id}: #{txn.to_text}")
next
end
unless wallet.prefix?(txn.prefix)