Sha256: 1ed628e51840d3419f3f55f07e952c78890d60465aa20ebbcae693c4ae8f5b05

Contents?: true

Size: 924 Bytes

Versions: 26

Compression:

Stored size: 924 Bytes

Contents

module Stellar
  class TransactionEnvelope

    # 
    # 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.
    # 
    # @param *key_pairs [Array<Stellar::KeyPair>] The key pairs to check the envelopes signatures against
    # 
    # @return [Boolean] true if all signatures are from the provided key_pairs and validly sign the tx's hash
    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

    def hash
      Digest::SHA256.digest(to_xdr)
    end
  end
end

Version data entries

26 entries across 26 versions & 3 rubygems

Version Path
stellar-base-0.15.0 lib/stellar/transaction_envelope.rb
stellar-base-0.14.0 lib/stellar/transaction_envelope.rb
stellar-base-0.13.0 lib/stellar/transaction_envelope.rb
stellar-base-0.12.0 lib/stellar/transaction_envelope.rb
stellar-base-0.11.0 lib/stellar/transaction_envelope.rb
auction-ruby-base-0.1.3 lib/stellar/transaction_envelope.rb
auction-ruby-base-0.1.2 lib/stellar/transaction_envelope.rb
auction-ruby-base-0.1.1 lib/stellar/transaction_envelope.rb
stellar-base-0.10.0 lib/stellar/transaction_envelope.rb
stellar-base-0.9.0 lib/stellar/transaction_envelope.rb
stellar-base-0.8.0 lib/stellar/transaction_envelope.rb
stellar-base-0.7.0 lib/stellar/transaction_envelope.rb
stellar-base-0.6.1 lib/stellar/transaction_envelope.rb
stellar-base-0.6.0 lib/stellar/transaction_envelope.rb
stellar-base-0.5.0 lib/stellar/transaction_envelope.rb
stellar-base-0.4.0 lib/stellar/transaction_envelope.rb
open-core-0.3.0 lib/stellar/transaction_envelope.rb
stellar-base-0.3.0 lib/stellar/transaction_envelope.rb
stellar-base-0.2.0 lib/stellar/transaction_envelope.rb
stellar-base-0.1.4 lib/stellar/transaction_envelope.rb