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

Commit

Permalink
fix(wallet): set payment probe fee limit to 100000 sats
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelton committed Mar 29, 2020
1 parent ce6265d commit ed23de0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 12 deletions.
9 changes: 7 additions & 2 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,13 @@ module.exports = {
useAddressFallback: false,
retryCount: 2, // Number of retries for pay invoice failure
feeIncrementExponent: 1.1, // Exponent applied to fee limit on payment retry attempts
probeTimeout: 30, // Upper limit on the amount of time (s) we should spend when attempting to probe the payment
paymentTimeout: 30, // Upper limit on the amount of time (s) we should spend when attempting to fulfill the payment
},

payments: {
timeout: 30, // Upper limit on the amount of time (s) we should spend when attempting to probe a payment
feeLimit: 1000, // Upper limit on the routing fees we should accept when sending payment without a limit
probeTimeout: 30, // Upper limit on the amount of time (s) we should spend when attempting to send a payment
probeFeeLimit: 1000, // Upper limit on the routing fees we want to consider in payment probes
},

autopay: {
Expand Down
1 change: 1 addition & 0 deletions renderer/reducers/payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ export const payInvoice = ({
if (infoSelectors.hasRouterSupport(getState())) {
payload = {
...payload,
feeLimit,
timeoutSeconds: PAYMENT_TIMEOUT,
}

Expand Down
33 changes: 23 additions & 10 deletions services/grpc/router.methods.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
import { randomBytes } from 'crypto'
import config from 'config'
import get from 'lodash/get'
import defaults from 'lodash/defaults'
import omitBy from 'lodash/omitBy'
import isNil from 'lodash/isNil'
import { grpcLog } from '@zap/utils/log'
import { logGrpcCmd } from './helpers'

const PAYMENT_PROBE_TIMEOUT = config.invoices.probeTimeout
const PAYMENT_TIMEOUT = config.payments.timeout
const PAYMENT_FEE_LIMIT = config.payments.feeLimit

const PAYMENT_PROBE_TIMEOUT = config.payments.probeTimeout
const PAYMENT_PROBE_FEE_LIMIT = config.payments.probeFeeLimit

// ------------------------------------
// Wrappers / Overrides
Expand All @@ -17,15 +23,15 @@ const PAYMENT_PROBE_TIMEOUT = config.invoices.probeTimeout
* @returns {Promise} The route route when state is SUCCEEDED
*/
async function probePayment(options) {
logGrpcCmd('Router.probePayment', options)

// Use a payload that has the payment hash set to some random bytes.
// This will cause the payment to fail at the final destination.
const payload = {
...options,
const payload = defaults(omitBy(options, isNil), {
payment_hash: new Uint8Array(randomBytes(32)),
timeout_seconds: get(options, 'timeout_seconds', PAYMENT_PROBE_TIMEOUT),
}
timeout_seconds: PAYMENT_PROBE_TIMEOUT,
fee_limit_sat: PAYMENT_PROBE_FEE_LIMIT,
})

logGrpcCmd('Router.probePayment', payload)

let result
let error
Expand Down Expand Up @@ -84,10 +90,17 @@ async function probePayment(options) {
/**
* sendPayment - Call lnd grpc sendPayment method.
*
* @param {object} payload Payload
* @param {object} options Options
* @returns {Promise} Original payload augmented with lnd sendPayment response data
*/
async function sendPayment(payload = {}) {
async function sendPayment(options = {}) {
// Use a payload that has the payment hash set to some random bytes.
// This will cause the payment to fail at the final destination.
const payload = defaults(omitBy(options, isNil), {
timeout_seconds: PAYMENT_TIMEOUT,
fee_limit: PAYMENT_FEE_LIMIT,
})

logGrpcCmd('Router.sendPayment', payload)

// Our response will always include the original payload.
Expand Down

0 comments on commit ed23de0

Please sign in to comment.