lib/zold/patch.rb in zold-0.14.12 vs lib/zold/patch.rb in zold-0.14.13

- old
+ new

@@ -56,16 +56,27 @@ else @log.debug("The baseline of #{@txns.count} transactions ignored") end @network = wallet.network end - if wallet.network != @network - raise "The wallet is from a different network '#{wallet.network}', ours is '#{@network}'" + unless wallet.network == @network + @log.error("The wallet is from a different network '#{wallet.network}', ours is '#{@network}'") + return end - raise 'Public key mismatch' if wallet.key != @key - raise "Wallet ID mismatch: #{@id} != #{wallet.id}" if wallet.id != @id + unless wallet.key == @key + @log.error('Public key mismatch') + return + end + unless wallet.id == @id + @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}") next