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

Commit

Permalink
fix(lnd): support probing in lnd v0.10.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelton committed May 3, 2020
1 parent d3d5e23 commit 32bd2be
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions services/grpc/router.methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ async function probePayment(options) {
return new Promise((resolve, reject) => {
grpcLog.time('probePayment')
const call = this.service.sendPayment(payload)
let route

call.on('data', data => {
grpcLog.debug('PROBE DATA :%o', data)
Expand All @@ -59,16 +60,18 @@ async function probePayment(options) {

case 'FAILED_INCORRECT_PAYMENT_DETAILS':
grpcLog.info('PROBE SUCCESS: %o', data)
// Prior to lnd v0.10.0 sendPayment would return a single route under the `route` key.
route = data.route || data.htlcs[0].route
// FIXME: For some reason the customRecords key is corrupt in the grpc response object.
// For now, assume that if a custom_record key is set that it is a keysend record and fix it accordingly.
data.route.hops = data.route.hops.map(hop => {
route.hops = route.hops.map(hop => {
Object.keys(hop.customRecords).forEach(key => {
hop.customRecords[KEYSEND_PREIMAGE_TYPE] = hop.customRecords[key]
delete hop.customRecords[key]
})
return hop
})
result = data.route
result = route
break

default:
Expand Down

0 comments on commit 32bd2be

Please sign in to comment.