Skip to main content

executeMultiHopPayment

@totemsdk/omnia-router


@totemsdk/omnia-router / executeMultiHopPayment

Function: executeMultiHopPayment()

executeMultiHopPayment(ops, channels, route, paymentRequest, leaseProviders): Promise<PaymentResult>

Execute a single-token multi-hop payment atomically:

  1. Forward phase — lock HTLCs across each hop in route.hops.
  2. Reveal phase — reveal preimage via fulfillHTLC in reverse order.

Rollback (best-effort timeoutHTLC on all still-pending locks) fires on ANY failure, including failures that occur during the reveal phase — so stranded HTLCs are never left behind silently.

paymentRequest.preimage MUST be set (buildPaymentRequest sets it).

The channels map is updated in-place after each HTLC operation.

Parameters​

ops​

ChannelOps

channels​

Map<string, RouterChannel>

route​

Route

paymentRequest​

PaymentRequest

leaseProviders​

Map<string, unknown>

Returns​

Promise<PaymentResult>