Module: Stellar::Concerns::Transaction

Included in:
FeeBumpTransaction, Transaction, TransactionV0
Defined in:
lib/stellar/concerns/transaction.rb

Instance Method Summary collapse

Instance Method Details

#apply_defaultsObject



42
43
44
45
46
47
# File 'lib/stellar/concerns/transaction.rb', line 42

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

#hashObject



17
18
19
# File 'lib/stellar/concerns/transaction.rb', line 17

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

#merge(other) ⇒ Object



21
22
23
24
25
# File 'lib/stellar/concerns/transaction.rb', line 21

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

#sign(key_pair) ⇒ Object



9
10
11
# File 'lib/stellar/concerns/transaction.rb', line 9

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

#sign_decorated(key_pair) ⇒ Object



13
14
15
# File 'lib/stellar/concerns/transaction.rb', line 13

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

#signature_baseObject

Returns the string of bytes that, when hashed, provide the value which should be signed to create a valid stellar transaction signature



5
6
7
# File 'lib/stellar/concerns/transaction.rb', line 5

def signature_base
  signature_base_prefix + to_xdr
end

#to_operationsArray<Operation>

Extracts the operations from this single transaction, setting the source account on the extracted operations.

Useful for merging transactions.

Returns:



34
35
36
37
38
39
40
# File 'lib/stellar/concerns/transaction.rb', line 34

def to_operations
  # FIXME: what was the purpose of this?
  # cloned = Marshal.load Marshal.dump(operations)
  operations.each do |op|
    op. ||= 
  end
end