Class: Stellar::PathPaymentResult

Inherits:
XDR::Union
  • Object
show all
Includes:
XDR::Namespace
Defined in:
lib/stellar/path_payment_result.rb,
generated/stellar/path_payment_result.rb,
generated/stellar/path_payment_result/success.rb

Defined Under Namespace

Classes: Success

Instance Method Summary collapse

Instance Method Details

#send_amountObject

send_amount returns the actual amount paid for the corresponding PathPaymentOp to this result.



6
7
8
9
10
11
12
13
14
# File 'lib/stellar/path_payment_result.rb', line 6

def send_amount
  s = success!
  return s.last.amount if s.offers.blank?

  source_asset = s.offers.first.asset_bought
  source_offers = s.offers.take_while{|o| o.asset_bought == source_asset}

  source_offers.map(&:amount_bought).sum
end