Class: StellarSpectrum::SendPayment

Inherits:
Object
  • Object
show all
Extended by:
LightService::Organizer
Defined in:
lib/stellar_spectrum/services/send_payment.rb

Class Method Summary collapse

Class Method Details

.actionsObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/stellar_spectrum/services/send_payment.rb', line 34

def self.actions
  [
    IncrementTries,
    InitStellarClient,
    InitRedis,
    GetChannelAccounts,
    reduce_if(->(c) {c[:force_transaction_source].nil?}, [
      GetLockedAccounts,
      GetAvailableChannels,
      reduce_if(->(c) {c.available_channels.empty?}, SendingPayment::Retry),
      PickChannel,
    ]),
    reduce_if(->(c) {c[:force_transaction_source].present?}, [
      execute(->(c) {c[:channel_account] = c[:force_transaction_source]}),
    ]),
    GetSequenceNumber,
    LockChannel,
    reduce_if(->(c) {!c.successfully_locked}, SendingPayment::Retry),
    SendingPayment::SendAsset,
    SendingPayment::AttemptReleaseLock,
  ]
end

.call(from:, to:, amount:, memo: nil, tries: 0, seeds:, redis_url:, horizon_url:, force_transaction_source: nil, force_sequence_number: nil, force_lock: false) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/stellar_spectrum/services/send_payment.rb', line 6

def self.call(
  from:,
  to:,
  amount:,
  memo: nil,
  tries: 0,
  seeds:,
  redis_url:,
  horizon_url:,
  force_transaction_source: nil,
  force_sequence_number: nil,
  force_lock: false
)
  with(
    from: from,
    to: to,
    amount: amount,
    memo: memo,
    tries: tries,
    seeds: seeds,
    redis_url: redis_url,
    horizon_url: horizon_url,
    force_transaction_source: force_transaction_source,
    force_sequence_number: force_sequence_number,
    force_lock: force_lock,
  ).reduce(actions)
end