decrypt

fun decrypt(add: UpdateAddHtlc, privateKey: PrivateKey): Either<FailureMessage, PaymentOnion.FinalPayload>

Decrypt the onion packet of a received htlc. We expect to be the final recipient, and we validate that the HTLC fields match the onion fields (this prevents intermediate nodes from sending an invalid amount or expiry).

Return

either:

  • a decrypted and valid onion final payload

  • or a Bolt4 failure message that can be returned to the sender if the HTLC is invalid

Parameters

add

incoming htlc.

privateKey

this node's private key.