Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
fix(lnd): fetch dest pubkey from payment htlcs list
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelton committed May 10, 2020
1 parent d8106ec commit dc41030
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions renderer/reducers/payment/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import config from 'config'
import get from 'lodash/get'
import { decodePayReq, getNodeAlias, generatePreimage } from '@zap/utils/crypto'
import { convert } from '@zap/utils/btc'
import { getIntl } from '@zap/i18n'
Expand Down Expand Up @@ -39,13 +40,23 @@ export const decoratePayment = (payment, nodes = []) => {
payment.rPreimage && Buffer.from(payment.rPreimage, 'hex').toString('hex')
}

// Convert the preimage to a hex string.
// Convert the payment hash to a hex string.
if (!payment.paymentHash) {
decoration.paymentHash = payment.rHash && Buffer.from(payment.rHash, 'hex').toString('hex')
}

// First try to get the pubkey from payment.path
let pubkey = payment.path && payment.path[payment.path.length - 1]
// First try to get the pubkey from payment.htlcs list (lnd 0.9+)
// Fallback to looking in the legacy payment.path property.
let pubkey
if (payment.htlcs) {
const hops = get(payment, 'htlcs[0].route.hops', [])
const lasthop = hops[hops.length - 1]
if (lasthop) {
pubkey = lasthop.pubKey
}
} else if (payment.path) {
pubkey = payment.path[payment.path.length - 1]
}

// If we don't have a pubkey, try to get it from the payment request.
if (!pubkey && payment.paymentRequest) {
Expand Down

0 comments on commit dc41030

Please sign in to comment.