lib/zold/signature.rb in zold-0.16.27 vs lib/zold/signature.rb in zold-0.16.28

- old
+ new

@@ -31,10 +31,14 @@ # Copyright:: Copyright (c) 2018 Yegor Bugayenko # License:: MIT module Zold # A signature class Signature + def initialize(network = 'test') + @network = network + end + # Sign the trasnsaction and return the signature. # +pvt+:: Private RSA key # +id+:: Paying wallet ID # +txn+:: The transaction def sign(pvt, id, txn) @@ -50,10 +54,10 @@ # +txn+: Transaction to validate def valid?(pub, id, txn) raise 'pub must be of type Key' unless pub.is_a?(Key) raise 'id must be of type Id' unless id.is_a?(Id) raise 'txn must be of type Txn' unless txn.is_a?(Txn) - pub.verify(txn.sign, body(id, txn)) + pub.verify(txn.sign, body(id, txn)) && (@network != Wallet::MAINET || id != Id::ROOT || pub == Key::ROOT) end private # Create the body for transaction signature.