Class: Stellar::TransactionEnvelope

Inherits:
Object
  • Object
show all
Defined in:
lib/stellar/transaction_envelope.rb

Instance Method Summary collapse

Instance Method Details

#merge(other) ⇒ Object


29
30
31
32
33
# File 'lib/stellar/transaction_envelope.rb', line 29

def merge(other)
  merged_tx = tx.merge(other.tx)
  merged_tx.signatures = [signatures, other.signatures]
  merged_tx
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.

Parameters:

  • key_pairs (Array<Stellar::KeyPair>)

    The key pairs to check the envelopes signatures against

Returns:

  • (Boolean)

    true if all signatures are from the provided key_pairs and validly sign the tx's hash


15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/stellar/transaction_envelope.rb', line 15

def signed_correctly?(*key_pairs)
  return false if signatures.empty?

  tx_hash = tx.hash
  keys_by_hint = key_pairs.index_by(&:signature_hint)

  signatures.all? do |sig|
    key_pair = keys_by_hint[sig.hint]
    break false if key_pair.nil?

    key_pair.verify(sig.signature, tx_hash)
  end
end