lib/bitcoin/protocol/alert.rb in bitcoin-ruby-0.0.1 vs lib/bitcoin/protocol/alert.rb in bitcoin-ruby-0.0.2
- old
+ new
@@ -1,5 +1,7 @@
+# encoding: ascii-8bit
+
module Bitcoin
module Protocol
class Alert < Struct.new(:version, :relay_until, :expiration, :id, :cancel, :set_cancel,
:min_ver, :max_ver, :set_sub_ver, :priority, :comment, :status_bar, :reserved)
@@ -9,16 +11,13 @@
def initialize(values, alert_payload=nil, alert_signature=nil)
@payload, @signature = alert_payload, alert_signature
super(*values)
end
-
- Valid_Keys = [ "04fc9702847840aaf195de8442ebecedf5b095cdbb9bc716bda9110971b28a49e0ead8564ff0db22209e0374782c093bb899692d524e9d6a6956e7c5ecbcd68284" ]
-
def valid_signature?
return false unless @payload && @signature
hash = Digest::SHA256.digest(Digest::SHA256.digest(@payload))
- Valid_Keys.any?{|public_key| Bitcoin.verify_signature(hash, @signature, public_key) }
+ Bitcoin.network[:alert_pubkeys].any?{|public_key| Bitcoin.verify_signature(hash, @signature, public_key) }
end
def self.parse(payload)
count, payload = Bitcoin::Protocol.unpack_var_int(payload)