Skip to content

Commit

Permalink
Add fee config
Browse files Browse the repository at this point in the history
  • Loading branch information
hsjoberg committed Apr 19, 2021
1 parent 4686c99 commit 920b45e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions config/default.json_TEMPLATE
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
"htlcWaitMs": 50,
"minimumPaymentMultiplier": 5,
"maximumPaymentSat": 1000000,
"fee": {
"maxSat": 40000,
"maxSatPerVByte": 200,
},
"backend": "lnd",
"backendConfig": {
"lndNode": "127.0.0.1:9735",
Expand Down
5 changes: 5 additions & 0 deletions config/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"serverHost": "127.0.0.1:8089",
"backend": "lnd",
"htlcWaitMs": 10,
"fee": {
"maxSat": 40000,
"maxSatPerVByte": 200,
"subsidyFactor": 1
},
"minimumPaymentMultiplier": 5,
"maximumPaymentSat": 1000000,
"backendConfig": {
Expand Down
1 change: 1 addition & 0 deletions src/services/ondemand-channel/api/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export default function Register(
estimateFeeResponse = await estimateFee(lightning, Long.fromValue(maximumPaymentSat), 1);
} catch (e) {
// If we don't have enough funds we'll get here
reply.code(503);
const error: IErrorResponse = {
status: "ERROR",
reason: "Dunder is temporarily offline.",
Expand Down
4 changes: 3 additions & 1 deletion src/services/ondemand-channel/api/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ import config from "config";
import { MIN_CHANNEL_SIZE_SAT } from "../../../utils/constants";

export function checkFeeTooHigh(feerateSatPerByte: Long, feeSat: Long) {
return feerateSatPerByte.greaterThan(200) || feeSat.greaterThan(40000);
const maxSat = config.get<number>("fee.maxSat");
const maxSatPerVByte = config.get<number>("fee.maxSatPerVByte");
return feerateSatPerByte.greaterThan(maxSatPerVByte) || feeSat.greaterThan(maxSat);
}

export function getMinimumPaymentSat(feeEstimateSat: Long) {
Expand Down
3 changes: 3 additions & 0 deletions src/utils/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ export function assertEnvironment() {
config.get("htlcWaitMs");
config.get("minimumPaymentMultiplier");
config.get("maximumPaymentSat");
config.get("fee");
config.get("fee.maxSat");
config.get("fee.maxSatPerVByte");
config.get("backend");
config.get("backendConfig.lndNode");
config.get("backendConfig.grpcServer");
Expand Down

0 comments on commit 920b45e

Please sign in to comment.