Class: Stellar::TransactionEnvelope
- Inherits:
-
XDR::Struct
- Object
- XDR::Struct
- Stellar::TransactionEnvelope
- Defined in:
- lib/stellar/transaction_envelope.rb,
generated/stellar/transaction_envelope.rb
Instance Method Summary collapse
- #hash ⇒ Object
-
#signed_correctly?(*key_pairs) ⇒ Boolean
Checks to ensure that every signature for the envelope is a valid signature of one of the provided ‘key_pairs`.
Instance Method Details
#hash ⇒ Object
28 29 30 |
# File 'lib/stellar/transaction_envelope.rb', line 28 def hash Digest::SHA256.digest(to_xdr) end |
#signed_correctly?(*key_pairs) ⇒ Boolean
Checks to ensure that every signature for the envelope is a valid signature of one of the provided ‘key_pairs`
NOTE: this does not do any authorization checks, which requires access to the current ledger state.
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/stellar/transaction_envelope.rb', line 14 def signed_correctly?(*key_pairs) hash = tx.hash return false if signatures.empty? key_index = key_pairs.index_by(&:signature_hint) signatures.all? do |sig| key_pair = key_index[sig.hint] break false if key_pair.nil? key_pair.verify(sig.signature, hash) end end |