Sha256: bf1d2b704867aa01c380e181b018f74742fe0624f8cd5261c11f739130c0c2f5

Contents?: true

Size: 1.21 KB

Versions: 7

Compression:

Stored size: 1.21 KB

Contents

module Stellar::Concerns
  module Transaction
    # Returns the string of bytes that, when hashed, provide the value which
    # should be signed to create a valid stellar transaction signature
    def signature_base
      signature_base_prefix + to_xdr
    end

    def sign(key_pair)
      key_pair.sign(hash)
    end

    def sign_decorated(key_pair)
      key_pair.sign_decorated(hash)
    end

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

    def merge(other)
      cloned = Marshal.load Marshal.dump(self)
      cloned.operations += other.to_operations
      cloned
    end

    #
    # Extracts the operations from this single transaction,
    # setting the source account on the extracted operations.
    #
    # Useful for merging transactions.
    #
    # @return [Array<Operation>] the operations
    def to_operations
      # FIXME: what was the purpose of this?
      # cloned = Marshal.load Marshal.dump(operations)
      operations.each do |op|
        op.source_account ||= source_account
      end
    end

    def apply_defaults
      self.operations ||= []
      self.fee ||= 100
      self.memo ||= Stellar::Memo.new(:memo_none)
      self.ext ||= Stellar::Transaction::Ext.new 0
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
stellar-base-0.24.0 lib/stellar/concerns/transaction.rb
stellar-base-0.24.0.pre.1 lib/stellar/concerns/transaction.rb
stellar-base-0.23.1 lib/stellar/concerns/transaction.rb
stellar-base-0.23.0 lib/stellar/concerns/transaction.rb
stellar-base-0.23.0.rc2 lib/stellar/concerns/transaction.rb
stellar-base-0.23.0.rc1 lib/stellar/concerns/transaction.rb
stellar-base-0.23.0.pre1 lib/stellar/concerns/transaction.rb