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

Commit

Permalink
fix(lnd): ensure fee limit is correctly set
Browse files Browse the repository at this point in the history
  • Loading branch information
mrfelton committed May 17, 2020
1 parent 88b4bcc commit 762c137
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
14 changes: 8 additions & 6 deletions renderer/reducers/payment/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,9 @@ export const payInvoice = ({
paymentHash: route.paymentHash ? Buffer.from(route.paymentHash, 'hex') : null,
route: routeToUse,
})
if (result.failure) {
throw new Error(result.failure.code)
}
} catch (error) {
if (error.message === 'unknown service routerrpc.Router') {
// We don't know for sure that the node has been compiled with the Router service.
Expand All @@ -259,11 +262,6 @@ export const payInvoice = ({
throw error
}
}
if (result.failure) {
const error = new Error(result.failure.code)
error.details = data
throw error
}
}

// Otherwise, just use sendPayment.
Expand All @@ -274,7 +272,11 @@ export const payInvoice = ({

// For older versions use the legacy Lightning.sendPayment method.
else {
data = await routerSendPayment(payload)
if (payload.feeLimitSat) {
payload.feeLimit = { fixed: payload.feeLimitSat }
delete payload.feeLimitSat
}
await grpc.services.Lightning.sendPayment(payload)
}

dispatch(paymentSuccessful(data))
Expand Down
8 changes: 4 additions & 4 deletions renderer/reducers/payment/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export const prepareKeysendPayload = (pubkey, amt, feeLimit) => {
return {
...getPaymentConfig(),
dest: Buffer.from(pubkey, 'hex'),
feeLimit: feeLimit ? { fixed: feeLimit } : null,
feeLimitSat: feeLimit,
paymentHash: sha256digest(preimage),
amt,
finalCltvDelta: DEFAULT_CLTV_DELTA,
Expand All @@ -130,7 +130,7 @@ export const prepareBolt11Payload = (payReq, amt, feeLimit) => {
return {
...getPaymentConfig(),
paymentRequest: invoice.paymentRequest,
feeLimit: feeLimit ? { fixed: feeLimit } : null,
feeLimitSat: feeLimit,
amt: millisatoshis ? null : amt,
}
}
Expand All @@ -149,7 +149,7 @@ export const prepareKeysendProbe = (pubkey, amt, feeLimit) => {
return {
...getPaymentConfig(),
dest: Buffer.from(pubkey, 'hex'),
feeLimit: feeLimit ? { fixed: feeLimit } : null,
feeLimitSat: feeLimit,
amt,
finalCltvDelta: DEFAULT_CLTV_DELTA,
paymentHash: sha256digest(preimage),
Expand All @@ -173,7 +173,7 @@ export const prepareBolt11Probe = (payReq, feeLimit) => {
return {
...getPaymentConfig(),
dest: Buffer.from(pubkey, 'hex'),
feeLimit: feeLimit ? { fixed: feeLimit } : null,
feeLimitSat: feeLimit,
amtMsat: millisatoshis,
finalCltvDelta: getTag(invoice, 'min_final_cltv_expiry') || DEFAULT_CLTV_DELTA,
}
Expand Down
2 changes: 1 addition & 1 deletion services/grpc/router.methods.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const defaultProbeOptions = {

const defaultPaymentOptions = {
timeoutSeconds: PAYMENT_TIMEOUT,
feeLimit: PAYMENT_FEE_LIMIT,
feeLimitSat: PAYMENT_FEE_LIMIT,
allowSelfPayment: true,
}

Expand Down

0 comments on commit 762c137

Please sign in to comment.