lib/zold/patch.rb in zold-0.6.4 vs lib/zold/patch.rb in zold-0.7
- old
+ new
@@ -30,13 +30,17 @@
class Patch
def start(wallet)
@id = wallet.id
@key = wallet.key
@txns = wallet.txns
+ @network = wallet.network
end
def join(wallet)
+ if wallet.network != @network
+ raise "The wallet is from a different network '#{wallet.version}', ours is '#{@network}'"
+ end
negative = @txns.select { |t| t.amount.negative? }
max = negative.empty? ? 0 : negative.max_by(&:id).id
wallet.txns.each do |txn|
next if @txns.find { |t| t == txn }
next if
@@ -52,10 +56,10 @@
# Returns TRUE if the file was actually modified
def save(file, overwrite: false)
before = ''
before = File.read(file) if File.exist?(file)
wallet = Zold::Wallet.new(file)
- wallet.init(@id, @key, overwrite: overwrite)
+ wallet.init(@id, @key, overwrite: overwrite, network: @network)
@txns.each { |t| wallet.add(t) }
after = File.read(file)
before != after
end
end